1

From RabbitMQ - Message order of delivery

Section 4.7 of the AMQP 0-9-1 core specification explains the conditions under which ordering is guaranteed: messages published in one channel, passing through one exchange and one queue and one outgoing channel will be received in the same order that they were sent. RabbitMQ offers stronger guarantees since release 2.7.0.

Does this hold with EasyNetQ? I would have expected it to hold, but I'm sometimes (but not always) seeing a different behaviour.

If the consumer is synchronized (not my case yet; I have locking but it begins after an "if" which is always false in this case), should I trust messages to be consumed in the order they are published? (Same type of message, same origin, going to same destination) Or are there other elements at play here internal to EasyNetQ which I should be aware of which don't preserve the message order of delivery?

Community
  • 1
  • 1
Jason Kealey
  • 7,988
  • 11
  • 42
  • 55

1 Answers1

3

EasyNetQ implements a single consumer thread per IBus instance, so if you use the standard non-async subscribe method your message handler will fire synchronously in the same order that messages are delivered by RabbitMQ. There shouldn't be any need to implement a lock. If you use the async subscribe, the handlers will still be called in order, but of course they may ACK out of order depending on how you implement your async handler.

Mike Hadlow
  • 9,427
  • 4
  • 45
  • 37
  • 1
    There are two different applications to consume the same message queue, how can we guarantee that only one application consume a message. (Both applications will listen the queue, if one of them fails another one continue to consume, if one of them is consuming another one waits) – Oguz Karadenizli Mar 22 '15 at 20:27