How do I delete all messages from a single queue using the cli? I have the queue name and I want to clean it.
151
votes
10 Answers
134
votes
rabbitmqadmin is the perfect tool for this
rabbitmqadmin purge queue name=name_of_the_queue_to_be_purged
18
votes
17
votes
17
votes
9
votes
5
votes
I guess its late but for others reference, this can be done with pika
import pika
host_ip = #host ip
channel = pika.BlockingConnection(pika.ConnectionParameters(host_ip,
5672,
"/",
credentials=pika.PlainCredentials("username","pwd"))).channel()
print "deleting queue..", channel.queue_delete(queue=queue_name)
4
votes
In order to delete only messages from the queue use :
sudo rabbitmqctl --node <nodename> purge_queue <queue_name>
In order to delete a queue which is empty(--if-empty) or has no consumers(--if-unused) use :
sudo rabbitmqctl --node <nodename> delete_queue <queue_name> --if-empty
or
sudo rabbitmqctl --node <nodename> delete_queue <queue_name> --if-unused
3
votes
I have successfully used ampq-purge
from amqp-utils to do this:
git clone https://github.com/dougbarth/amqp-utils.git
cd amqp-utils
# extracted from Rakefile
echo "source 'https://rubygems.org'
gem 'amqp', '~> 0.7.1'
gem 'trollop', '~> 1.16.2'
gem 'facets', '~> 2.9'
gem 'clio', '~> 0.3.0'
gem 'json', '~> 1.5'
gem 'heredoc_unindent', '~> 1.1.2'
gem 'msgpack', '~> 0.4.5'" > Gemfile
bundle install --path=$PWD/gems
export RUBYLIB=.
export GEM_HOME=$PWD/gems/ruby/1.9.1
ruby bin/amqp-purge -v -V /vhost -u user -p queue
# paste password at prompt