Send to NATS. get from NATS Streaming (or JetStream?)

152 views
Skip to first unread message

Oleg Trautvein

unread,
Apr 9, 2021, 7:01:18 PM4/9/21
to nats
Hello.
I saw here https://asciinema.org/a/282135 (1:34) messages published with nats-pub are available with stan-sub.

I deployed the stan helm chart with the following values
stan:
  replicas: 3 
affinity: # I have only 2 nodes now
  podAntiAffinity: {}
store:
  cluster:
    enabled: true

So, messages from nats-pub are not available with stan-pub:
~ # stan-sub -c nats -s nats foo &
~ # Connected to nats clusterID: [nats] clientID: [stan-sub]
Listening on [foo], clientID=[stan-sub], qgroup=[] durable=[]
[#1] Received: sequence:1 subject:"foo" data:"hello" timestamp:1618008322728517083
~ # stan-pub -c nats -s nats foo "Hello from stan-pub"
Published [foo] : 'Hello from stan-pub'
[#2] Received: sequence:2 subject:"foo" data:"Hello from stan-pub" timestamp:1618008403324659235
~ # nats-pub -s nats foo "Hello from nats-pub"
~ #

Could you please point me where I am wrong?

Why I need ->NATS -> NATS Streaming?
1. Fluentbit can send only to NATS
2. It is working in your video :-)

Also question - should we use NATS Streaming or JetStream?
Our requirements are:
1. Clustering for HA
2. Persistence to avoid data loss before we get messages from NATS. NATS/NATS Streaming /JetStream is a reliable buffer for messages.
3. We have several publishers (fluentbit) and only one subscriber (which consume NATS messages from external k8s cluster)

Thanks

iv...@synadia.com

unread,
Apr 9, 2021, 7:09:11 PM4/9/21
to nats
It is expected that messages published from NATS are NOT received by NATS Streaming. See last paragraph in our documentation: https://docs.nats.io/nats-streaming-concepts/relation-to-nats

I am not sure what the demo was doing, maybe it had a "nats replicator" running, or more stan messages were sent prior to the 2 messages sent with stan-pub that we see. I will ask Wally (the author of the demo) to check this.

As for the other question: you should use JetStream if this is a new project since JetStream is a replacement for NATS Streaming which will be discontinued in the future.
Also, with JetStream, messages published on NATS would make it to the persistence layer if you have a stream created that matches the subject.

Ivan.

Wally Quevedo

unread,
Apr 9, 2021, 8:43:07 PM4/9/21
to nat...@googlegroups.com
Hi Oleg, sorry for the confusion, it was just a coincidence that the subjects were being the same so it looks as if they are the same channel in both NATS and NATS Streaming. On the other hand, what you were expecting is exactly the user experience that you would get with using JetStream.

Thanks,

- Wally

--
You received this message because you are subscribed to the Google Groups "nats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to natsio+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/natsio/8d0cf132-ca74-4a77-8619-b8d77239a3d2n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages