Smart ways to purge a RabbitMQ queue

RabbitMQIn 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,

  1. Use RMQ admin interface to purge the queue.
  2. Redeclare the Queue with the command line tool rabbitmqctl
  3. Use rabbitmqadmin to purge the queue.
  4. 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.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.