"filter_subject" option is somehow added to the consumer option even when I don't specify it #4751
-
Hello, I came up with a strange problem, In the project I'm using Nats 2.10 and I want to take advantage of the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hey! Can you show us some code snippet how are you updating the consumer? |
Beta Was this translation helpful? Give feedback.
-
When you do a subscribe and don't specify a filter subject, the filter subject is set to the subject specified in the subscribe. Note that the subject specified on subscribe is used to locate the stream. I have verified that this is the case in go as it is in JavaScript. The NATS cli can leave it blank because it is tied to the stream when created, so the filter is optional there. The reasoning behind this on the clients is that if the stream is modified, the client will start receiving messages on subjects that it can possibly not handle properly. If the filter is provided it must match the subject or be a wildcard. With that aside, the API for subscribe is a bit challenging because it auto-creates a consumer. So for example in your code above, you use an inbox which will change every time that the consumer is run. A better alternative is to create the consumer as you want it, using the JSM apis ( |
Beta Was this translation helpful? Give feedback.
When you do a subscribe and don't specify a filter subject, the filter subject is set to the subject specified in the subscribe. Note that the subject specified on subscribe is used to locate the stream. I have verified that this is the case in go as it is in JavaScript. The NATS cli can leave it blank because it is tied to the stream when created, so the filter is optional there. The reasoning behind this on the clients is that if the stream is modified, the client will start receiving messages on subjects that it can possibly not handle properly. If the filter is provided it must match the subject or be a wildcard.
With that aside, the API for subscribe is a bit challenging because it a…