How Delete All the Queues From RabbitMQ?

Maciej
1 min readAug 20, 2021

Case

Let’s assume that for some reason a very large number of queues appeared in our RabbitMQ. We need to remove them efficiently and quickly, but how? Here are two easy ways to remove all queues from RabbitMQ

Method 1

We will do it with management plugin and policies

Steps:

  • Goto Management Console (localhost:15672)
  • Goto Admin tab
  • Goto Policies tab(on the right side)
  • Add Policy
  • Fill Fields
  • Virtual Host: Select
    Name: Expire All Policies(Delete Later)
    Pattern: .*
    Apply to: Queues
    Definition: expires with value 1 (change type from String to Number)
    Save
  • Checkout Queues tab again
  • All Queues must be deleted

🚨And don’t forget to remove policy!!!!!!.🚨

Method 2

We will do it with Management Command Line Tool. We can download it from link below:

RABBITMQADMIN

root@vagrant:/home/vagrant# wget https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/v3.9.3/deps/rabbitmq_management/bin/rabbitmqadmin -P /tmp
root@vagrant:/home/vagrant# chmod +x /tmp/rabbitmqadmin
root@vagrant:/home/vagrant# mv /tmp/rabbitmqadmin /usr/bin/
root@vagrant:/home/vagrant# rabbitmqadmin list queues name | awk '{print $2}' | xargs -I qn rabbitmqadmin delete queue name=qn

--

--

Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.