Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all the queues from RabbitMQ?

People also ask

How do I reset RabbitMQ?

To reset a running and responsive node, first stop RabbitMQ on it using rabbitmqctl stop_app and then reset it using rabbitmqctl reset: # on rabbit1 rabbitmqctl stop_app # => Stopping node rabbit@rabbit1 ... done.

Can I delete RabbitMQ?

Uninstalling RabbitMQ Server and Erlang OTP Select Uninstall a program. Right-click RabbitMQ Server, and then click Uninstall. Repeat steps 1-3 to uninstall Erlang OTP 18. Note: This script will delete all files related to RabbitMQ on C:\.

How do I get rid of RabbitMQ Vhost?

A virtual host can be deleted using rabbitmqctl's delete_vhost command which accepts virtual host name as the only mandatory argument.

Which command is used to delete all the messages from a queue or topic?

If you use the CLEAR command, all of the messages are cleared from the queue.


First, list your queues:

rabbitmqadmin list queues name

Then from the list, you'll need to manually delete them one by one:

rabbitmqadmin delete queue name='queuename'

Because of the output format, doesn't appear you can grep the response from list queues. Alternatively, if you're just looking for a way to clear everything (read: reset all settings, returning the installation to a default state), use:

rabbitmqctl stop_app
rabbitmqctl reset    # Be sure you really want to do this!
rabbitmqctl start_app

Actually super easy with management plugin and policies:

  • 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!!!!!!.


With rabbitmqadmin you can remove them with this one-liner:

rabbitmqadmin -f tsv -q list queues name | while read queue; do rabbitmqadmin -q delete queue name=${queue}; done

Try this:

 rabbitmqadmin list queues name | awk '{print $2}' | xargs -I qn rabbitmqadmin delete queue name=qn

In Rabbit version 3.7.10 you can run below command with root permission:

rabbitmqctl list_queues | awk '{ print $1 }' | xargs -L1 rabbitmqctl delete_queue

If you don't have rabbitmqadmin installed, try to purge queues with rabbitmqctl:

rabbitmqctl list_queues | awk '{ print $1 }' | xargs -L1 rabbitmqctl purge_queue