Matías Fidemraizer
Matías Fidemraizer

Reputation: 64943

Understanding unacked message requeue order

First of all, I quote the following text from RabbitMQ docs:

When a message is requeued, it will be placed to its original position in its queue, if possible. If not (due to concurrent deliveries and acknowledgements from other consumers when multiple consumers share a queue), the message will be requeued to a position closer to queue head.

Now imagine that there're two message (A and B) on the same queue, both are unacked: when official docs says "[...] closer to queue head" gives any guarantee of ordering?

Would message A be queued before B under any condition? For me the answer is no but I'm looking for advise.

Upvotes: 1

Views: 380

Answers (1)

theMayer
theMayer

Reputation: 16177

The short answer is

  • if both A and B are requeued, and
  • A was originally added to the queue before B, and
  • there is no consumer active on the queue between the time A was requeued and B was requeued,

then A will always be placed before B in the queue after both have been re-queued.

See my answer here for explanation as to why these assumptions are necessary.

Upvotes: 2

Related Questions