question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load balancing JetStream consumers

See original GitHub issue

Hello, I am currently using JetStream and I want to know if it’s possible to load balance my consumer, similar to specifying a queue group name in normal NATS. Right now, I have 2 instances of my application running, and each time a producer publishes a message, both instances of my application receive it (both using the same push consumer with a durable name). What I am looking for is a behavior similar to queue groups, where only one of the two instances receives the message.

I was told that this is possible in the nats.go library by subscribing to the stream using js.QueueSubscribe, however, I cannot seem to find this documented with nats.js. Can someone point me in the right direction? Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
aricartcommented, Jun 24, 2021

@csombok I have released nats v2.0.8 which exposes the queue option.

1reaction
csombokcommented, Jun 24, 2021

We are facing the same limitation and for us the only viable options is using the push based subscriber with STAN. Are there any ETA for merging this PR: https://github.com/nats-io/nats.deno/pull/162? As an alternative workaround we can use patch-package to have the fix as a patch in node_modules as a temporary solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JetStream - NATS Docs
JetStream consumers are 'views' on a stream, they are subscribed to (or pulled) by client applications to receive copies of (or to consume...
Read more >
Getting queues working in JetStream #510 - nats-io/nats.net
... to me is how can I register two consumers to listen on the same subject and ensure only one of them gets...
Read more >
NATS JetStream - ThinkMicroservices.com
By default, JetStream consumers are ephemeral. ... The controller creates the JetStream stream, pre-loads the stream with sample messages, ...
Read more >
Grokking NATS Consumers: Push-based queue groups
There are two problems queue groups solve. The first, which core NATS and JetStream supports, is the need for load balancing and scaling...
Read more >
Building Distributed Event Streaming Systems In Go With ...
The Pull based consumers let JetStream pull the messages from consumer systems. Pull based consumer systems are like work queues.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found