Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a queue in rabbit mq

Tags:

queue

rabbitmq

I am using rabbitmctl using pika library. I use the following code to create a Producer

#!/usr/bin/env python
import pika
import time
import json
import datetime


connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()



channel.queue_declare(queue='hello')

def callback(ch, method, properties, body):
    #print " current time: %s "  % (str(int((time.time())*1000)))

    print body

channel.basic_consume(callback,
                      queue='hello',
                      no_ack=True)


channel.start_consuming()

Since I create an existing queue everytime (Over-write the creation of queue in case if queue is not created) The queue has been corrupted due to this.and now I want to delete the queue..how do i do that?

like image 693
Shweta B. Patil Avatar asked Nov 11 '13 17:11

Shweta B. Patil


1 Answers

Since this seems to be a maintenance procedure, and not something you'll be doing routinely on your code, you should probably be using the RabbitMQ management plugin and delete the queue from there.

Anyway, you can delete it from pika with:

channel.queue_delete(queue='hello')

https://pika.readthedocs.org/en/latest/modules/channel.html#pika.channel.Channel.queue_delete

like image 67
Pedro Werneck Avatar answered Sep 23 '22 14:09

Pedro Werneck