NATS Queueing Walkthrough

If you have not already done so, you need to the CLI Tool and optionally the nats-server on your machine.

The instances don’t just subscribe to the subject but also automatically join a queue group ( by default)

2. Start a second member of the queue-group

In a new window

4. Publish a NATS message

You should see that only one of the my-queue group subscribers receives the message and replies it, and you can also see which one of the available queue-group subscribers processed the request from the reply message received (i.e. service instance A, B or C)

6. Publish another message

You can also send any number of requests back-to-back and see from the received messages the distribution of the those requests amongst the members of the queue-group (e.g. )

You can at any time start yet another service instance, or kill one and see how the queue-group automatically takes care of adding/removing those instances from the group.

See Also

{% embed url=”https://youtu.be/jLTVhP08Tq0?t=101“ %} Queue Groups NATS CLI {% endembed %}