RabbitMQ - Delete messages using the rabbitmqctl command

The rabbitmqctl command with the purge_queues option can be used to purge (permanently delete) all of the messages in a queue. The messages cannot be recovered after they are purged.

rabbitmqctl purge_queue queue_name


Optionally, the -p option can be used to specify the virtual host (vhost).

rabbitmqctl purge_queue queue_name -p vhost001


Before purging a queue, the list_queues command can be used to list the number of messages in the queue. In this example, there are 17 messages in queue002.

~]# rabbitmqctl list_queues -p vhost001

Listing queues for vhost vhost001
name     messages
queue001 0
queue002 17


You can specify the items you wish to include in the output, like this.

rabbitmqctl purge_queue queue002 -p vhost001


Something like this should be displayed.

Purging queue 'queue001' in vhost 'vhost001' ...


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 9d372 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |