了解未确认的消息重新排队顺序

Understanding unacked message requeue order

首先,我引用以下来自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.

现在假设在同一个队列中有两条消息(A 和 B),都未确认:当官方文档说“[...]更接近队列时head" 提供任何订购保证?

在任何情况下,消息 A 都会排在 B 之前排队吗?对我来说,答案是 但我正在寻求建议。

简短的回答是

  • 如果 A 和 B 都重新排队,并且
  • A本来是在B之前加入队列的,
  • 在 A 重新排队和 B 重新排队之间,队列上没有活动的消费者,

然后 A 将总是在队列中的 B 之前被放置在 B 之前。

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