Jetstream partitioning without impact on consumers #3554
-
Hello, I have a high-throughput use case with the following architecture: Stream 1:
Stream 2:
Message flow:
There is one jetstream subscription per App-B instance, to test2.1.> App-B and App-C should be able to consume past events, as they can be offline for some time (explaining the need for jetstream). With a 3 nats nodes cluster, I noticed a very high activity on one of the nodes, and very few activity for the others. Reading the doc, one idea could be to use the subject mapping to distribute the load on several server nodes. Mapping:
Stream 1:
Stream 2:
Stream 3:
Stream 4:
I'd still like my App-B and App-C to receive all the messages from Stream 2, 3 and 4 transparently, by using the same subjects, but it doesn't seem to work ("No matching streams for subject." when creating the consumer). Subscriptions are created this way:
(Taking example from https://github.com/nats-io/nats.java/blob/main/src/examples/java/io/nats/examples/jetstream/NatsJsPushSubQueueDurable.java) Did I get all of that correctly ? Is there a way to achieve such a scenario ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
If you are getting |
Beta Was this translation helpful? Give feedback.
-
Thank you @OpenGuidou that helps, I can open an issue github.com/nats-io/natscli or you can if you want, we'll get it sorted for next CLI release - though this is pretty weird must be some weird edge case in a dependency |
Beta Was this translation helpful? Give feedback.
-
It is expected: can not have more than one stream capturing the same subject(s) So here you have defined 3 streams capturing on Instead you have to create 3 consumers (one on each partition's stream) and subscribe 3 times (you can still pass it the same callback). |
Beta Was this translation helpful? Give feedback.
If you are getting
No matching streams for subject
I'm guessing the mapping has an issue. I wonder about thetest2...*
specifically and what the effect of that is I think it may be literal, not wild carded liketest2.*.*.*
. Can you post your server config? Also the actual stream config, either fromnats s info
or from the java management get stream info or the stream config code used to create the stream if you did it from Java.I'll need to ask about what the exact behavior of the partitioning should be.