Need Some General Info Regarding Client Design & partitioning #6437
-
We have a use case where we dont require strict ordering of messages, my 1st question is , lets say if i have 5 partitioned streams & 1 durable consumer per stream , how should the producing application produce to this stream, do we have any example blog on this? Is there some stream mapping functionality similar to subject transforms?
Is a stream equivalent to partition in kafka? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I too want to know more on Question 3 & 4. @jnmoyne @Jarema @ripienaar can you please help with some info on this, after reading this https://docs.nats.io/nats-concepts/subject_mapping it is quite unclear how nats handels partitioning and how it scales. |
Beta Was this translation helpful? Give feedback.
-
You can indeed use the In your example some applications publish messages on In your case since you do not need strict ordering, on the consumers that you create on each stream you can have a As mentioned the Core NATS mapping are defined at the account level, meaning that if you use static security you would define them in the server's configuration file. If you are using de-centralized operator JWT-based security then the mapping(s) would be part of the account's JWT. For an example of how to define Core NATS subject mappings in a server config based security model you can take a look at the examples in this blog post (not using subject transform to specifically insert a partition number token in the subject, but still using subject transformation). https://www.synadia.com/blog/multi-cluster-consistency-models |
Beta Was this translation helpful? Give feedback.
You can indeed use the
{{partition()}}
function in a subject mapping transform to insert a partition number token in the subject of the message being published. In this case you can use Core NATS subject transformation (which is part of the NATS account's settings) to have the NATS server(s) automatically insert that token in the subject as the message is being published, and before that message is captured (by the stream listening on that particular partition number).In your example some applications publish messages on
foo.<id>
and you have a subject mapping defined in your account's settings with source:foo.*
and destinationfoo.{{partition(5,1)}}.{{wildcard(1)}}
and then create 5 st…