Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting queues in RabbitMQ

Tags:

queue

rabbitmq

I have a few queues running with RabbitMQ. A few of them are of no use now, how can I delete them? Unfortunately I had not set the auto_delete option.

If I set it now, will it be deleted?

Is there a way to delete those queues now?

like image 489
Phalgun Avatar asked Jul 19 '11 06:07

Phalgun


People also ask

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 delete a consumer in RabbitMQ?

if you want to remove the consumer programmatically, calling the cancel method on the RabbitMQ channel should do.

What is auto delete in RabbitMQ?

An auto-delete queue will be deleted when its last consumer is cancelled (e.g. using the basic. cancel in AMQP 0-9-1) or gone (closed channel or connection, or lost TCP connection with the server). If a queue never had any consumers, for instance, when all consumption happens using the basic.


2 Answers

If you do not care about the data in management database; i.e. users, vhosts, messages etc., and neither about other queues, then you can reset via commandline by running the following commands in order:

WARNING: In addition to the queues, this will also remove any users and vhosts, you have configured on your RabbitMQ server; and will delete any persistent messages

rabbitmqctl stop_app rabbitmqctl reset rabbitmqctl start_app 

The rabbitmq documentation says that the reset command:

Returns a RabbitMQ node to its virgin state.

Removes the node from any cluster it belongs to, removes all data from the management database, such as configured users and vhosts, and deletes all persistent messages.

So, be careful using it.

like image 74
Faruk Sahin Avatar answered Oct 13 '22 00:10

Faruk Sahin


import pika  connection = pika.BlockingConnection(pika.ConnectionParameters(                'localhost')) channel = connection.channel()  channel.queue_delete(queue='queue-name')  connection.close() 

Install pika package as follows

$ sudo pip install pika==0.9.8 

The installation depends on pip and git-core packages, you may need to install them first.

On Ubuntu:

$ sudo apt-get install python-pip git-core 

On Debian:

$ sudo apt-get install python-setuptools git-core $ sudo easy_install pip 

On Windows: To install easy_install, run the MS Windows Installer for setuptools

> easy_install pip > pip install pika==0.9.8 
like image 23
Shweta B. Patil Avatar answered Oct 13 '22 00:10

Shweta B. Patil