1
votes

I am writing a wrapper around the .NET RabbitMQ library and have a question that isn't answered in the documentation as far as I can see, and I can't think of a way to verify it experimentally.

The documentation here states the following:

In most cases, RabbitMQ will acknowledge messages to publishers in the same order they were published (this applies for messages published on a single channel). However, publisher acknowledgements are emitted asynchronously and can confirm a single message or a group of messages. The exact moment when a confirm is emitted depends on the delivery mode of a message (persistent vs. transient) and the properties of the queue(s) the message was routed to (see above). Which is to say that different messages can be considered ready for acknowledgement at different times. This means that acknowledgements can arrive in a different order compared to their respective messages. Applications should not depend on the order of acknowledgements when possible.

So confirmations can be received out of order which I can cope with OK. However, how does this play with the Multiple flag that can be used?

Imagine the following scenario: I send messages 1,2,3,4 and 5. 1 fails and 2-5 succeed. The broker sends me a Nack for 1 and a single Ack for 5 with Multiple set to true. If order were guaranteed then I know I would get the Nack for 1 first and then I would know that the Ack was for 2-5. However, if they could be out of order, then I would assume, as I hadn't had a confirm for 1, that the Ack was for 1-5, and then when the Nack came in, it would be too late.

Are there guarantees somewhere where this scenario cannot happen?

1
Try also asking this in RabbitMQ google groupAlex Buyny

1 Answers

1
votes

This is the answer from the Google Group mentioned by Alex in the comments. Basically, this scenario can't happen.

Hi,

If you get a single nack for 1 then an ack for 5 with multiple=true this means 2-5 were all successful.

If 1 is delayed but 2-5 are not you should get 4 multiple=false acks with sequences 2-5 then a nack for 1.

It would be nicer if ack frames used ranges instead of the multiple flag but we are where we are.

Cheers
Karl