-
Hello, I have this test code in golang for nats jetstream.
func TestJSNoEcho(t *testing.T) { } I am expecting that since I am using same client for publish and subscribe and used no echo option. I should not be getting this message on subscription. But I am still getting that message meaning the log that I have inside handler for subscription prints. It will be really helpful if someone can help me identify where its going wrong. I want to stop echoing using jetstream. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Your issue is that you are publishing on nats core (where the no-echo) implements functionality - but you are creating a jetstream consumer that is processing messages from a stream that captures the message you are publishing. In JetStream you are processing messages from a stream, the fact that you also published that message is not known to JetStream and no-echo has no effect on that. |
Beta Was this translation helpful? Give feedback.
-
Hi @aricart , |
Beta Was this translation helpful? Give feedback.
-
the message you are publishing is through nats core, the JS publish functionality is simply making it a request so you can receive confirmation that your message was received by the server and written to the stream. Your subscription, however (even though the function is called |
Beta Was this translation helpful? Give feedback.
-
Also, since you seem to be getting started with JetStream, you should really look at the consumer functionality in the latest releases of the nats.go client, that will make your code simpler. See https://github.com/nats-io/nats.go/blob/main/jetstream/README.md |
Beta Was this translation helpful? Give feedback.
Your issue is that you are publishing on nats core (where the no-echo) implements functionality - but you are creating a jetstream consumer that is processing messages from a stream that captures the message you are publishing. In JetStream you are processing messages from a stream, the fact that you also published that message is not known to JetStream and no-echo has no effect on that.