In a recent benchmark, we got a very large queue in one of our online RabbitMQ cluster, which had more than 20mm messages in a single queue (occupying 5-6 gigabytes memory). Then how can we purge the large queue effectively?
There are basically fours ways to do that,
- Use RMQ admin interface to purge the queue.
- Redeclare the Queue with the command line tool rabbitmqctl
- Use rabbitmqadmin to purge the queue.
- Creating a script to purge the queue, like by python.
Note: Be careful about the above links, as some of them may clear all your queues.
In my case, it’s a bit different. The queue is too large to be consumed, and rabbitmqadmin was hanging on purging message. I set the Queue as durable and the message as transient (not in durable mode), it’s much easier to purge. All I need to do is to restart the RabbitMQ cluster to release all the messages. This takes less than 10 seconds, as I’ve confirmed that all the message in the RMQ cluster is discardable.