FAQ: How to purge unacked messages from a queue in RabbitMQ

Question: Multiple queues in our broker have a lot of messages. We tried to clear the piled-up messages by purging the queue, but only the ready state queues got deleted. There are still queues with messages that are in an "unacked" state. How can I clear them?

Close the channel that the unacked messages reside on, which requires you to add the messages back to the queue into a ready state. Then, purge the queue. The channel related to a consumer can be seen by pressing the queue with unacked messages. In the image, channel 54.175.17.49:38182 is related to the queue with unacked messages.

All channels on a connection will be closed when you close the connection that the channel belongs to. The connection can be closed via the management interface.

Press the connection that belongs to the chhannel, and them press "Force Close" from the bottom of the management interface.

A connection can also be closed via code, please read the article FAQ: How to close connections in RabbitMQ? for more information.

Consumer Timeout

Recent versions of RabbitMQ include the ability to configure a consumer timeout, which is the maximum time a consumer can spend processing a message before the channel is terminated.

If a consumer does not ack its delivery for more than the timeout value (30 minutes by default), its channel will be closed with a PRECONDITION_FAILED channel exception.

The timeout value is configurable in [rabbitmq.conf] (in milliseconds):

# 30 minutes in milliseconds
consumer_timeout = 1800000

CloudAMQP - industry leading RabbitMQ as a service

Start your managed cluster today. CloudAMQP is 100% free to try.

13,000+ users including these smart companies