-
I have a bunch of microservices that publish and subscribe to data events (implemented as NATS messages). I chose Jetstream and pull-based consumers because they provide persistence, message deduplication and sequence ordering which will be useful for exactly-once delivery as well as providing some fault tolerance for crashing of microservices. Initially I thought I could configure my consumers can handle a list of selective subjects i.e. Thus I send out all messages to all my microservices:
Both C1 and C2 are has pull-based consumers: var context = connection.CreateJetStreamContext();
var options = PullSubscribeOptions.Builder()
.WithStream("STREAM")
.WithDurable("C1") // The other one has C2
.Build();
var subscription = context.PullSubscribe("STREAM.>", options);
var msgs = subscription.Fetch(1, 1000);
if (!msgs.Any()) { ... }
...
msg.Ack(); Unfortunately when the C1 microservice publishes Why is this the case? The two consumers have differing durable names. Even though they consume the same filters shouldn't they receive the same messages? Is this because C1 ack's the message? If so I changed C1 so that it nack's the message but still no good: msg.Nak(); Am I missing something here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@Exagram Can you please show the stream configuation? The only thing I can think of is that the stream is configured as RetentionPolicy.WorkQueue, otherwise both consumers should get the message. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
STREAM.>
you would likely want to split your consumers by filter. You can useSTREAM.orders.>
,STREAM.notify.>
etc. You can also do thing likeSTREAM.*.fail
and that consumer would handle all types of f…