Can we create multiple jetstream consumers for a single subject #653
-
I am having a subject 'X.Y.Z' and in my application, I want to have 5 consumers consuming messages from 'X.Y.Z' subject. await _natsConnection!.ConnectAsync(); Note: This is a single node set up. I was checking jetstream workqueues, but i believe we have subject filtering if we need 5 consumers to consume from same subject. But in my usecase we dont have any subject filtering because its just one static subject name. Can anyone suggest if this is possible or not? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
You can have a single consumer and use the same consumer from 5 different clients to share the load. |
Beta Was this translation helpful? Give feedback.
-
@mtmk I believe what you mean by 5 different clients would mean like 5 different instances of my application or 5 different pods if hosted in k8s? Pls can you confirm what you mean by clients? What i am asking is if in a single application, i can loop through say 5 times to create a consumer with a specific configuration, where if I publish 10k messages , then 10k messages are load-balanced across 5 consumers running inside single instace of application. If this is possible, pls can you share the possible configurtion parameters? |
Beta Was this translation helpful? Give feedback.
-
I'd say overall percentage would be close to equal distribution but I'm out of my depth here when it comes to server internals. please feel free to jump on to |
Beta Was this translation helpful? Give feedback.
maybe this helps as well: https://nats-io.github.io/nats.net/documentation/jetstream/intro.html#streaming-temporal-decoupling-between-the-publishers-and-subscribers