2

According to https://nats.io/documentation/concepts/nats-queueing/

Synchronous queue subscribers must build in logic to process the message.

Does it mean that if there are 10 messages in the queue, only one subscriber gets the 1st message, and after reply something back, then the 2nd message will go to another subscriber?

If it's not, is there any messaging software or system can fit the situation I mentioned above?

zabop
  • 6,750
  • 3
  • 39
  • 84
Jo Huang
  • 35
  • 3

1 Answers1

2

The sentence highlighted means that clients that support asynchronous subscribers process messages in callbacks, asynchronously, and clients that have sync subscribers process them in place (or pass them to another goroutine/thread/etc).

NATS queue subscriptions (in both NATS core and NATS streaming) will fan messages out randomly between queue subscribers, not waiting for a response. If you have ten messages sent to two queue subscribers (A and B), queue subscriber A might process messages 1,3,4,6,9 and queue subscriber B would process messages 2,5,7,8,10. These may process messages at different rates, so with queue consumers NATS does not guarantee delivery order.

If you need to serially process messages between multiple queue subscribers, you'll need some sort of coordination - this may be a distributed transaction coordinator or a distributed lock.