Rabbitmq: Unacked message not going away after bro

2019-07-13 17:18发布

We have observed the following behavior of RabbitMQ and are trying to understand if it is correct and how to resolve it.

Scenario:

  1. A (persistent) message is delivered into a durable queue
  2. The (single) Consumer (Spring-AMQP) takes the message and starts processing => Message goes from READY to UNACK
  3. Now the broker is shut down => Client correctly reports "Channel shutdown"
  4. The consumer finishes the processing, but can not acknowledge the message as the broker is still down
  5. Broker is started again => Client reconnects

As a result, one message remains unack'ed forever (or until the client is restarted).

Side note: In the Rabbit Admin UI, I can see that two channels are existing now. The "dead" one that was created before the broker restart, containing the unacked message and a new one that is healthy.

Is this behavior expected to be like that? It seems to me "correct" in the way, that RabbitMQ can not know after the broker restart, whether the message processing was completed or not. But what solution would exist than to get that unacked message back into the queue and to heal the system without restarting the consumer process?

1条回答
神经病院院长
2楼-- · 2019-07-13 18:20

The RabbitMQ team monitors this mailing list and only sometimes answers questions on StackOverflow.


Is this behavior expected to be like that? It seems to me "correct" in the way, that RabbitMQ can not know after the broker restart, whether the message processing was completed or not.

Yes, you are observing expected behavior. RabbitMQ will re-enqueue the message once it determines that the consumer is really dead. Since your consumer re-connects with what must be the same consumer tag as before, it is up to that process to ack or nack the message.

查看更多
登录 后发表回答