Friday, 6 March 2015

Clear all queue in rabitmq

To clear a queue in rabbitmq or get no of jobs/consumers in/on the queue:

open python shell
enable a connection to the rabbitmq server
open a channel to the connection

import amqplib.client_0_8 as amqp 

host = <IP>
port = <PORT>
connection= amqp.Connection(host ='%s:%s' % (host, port),
                                                  userid = '<user>',
                                                  password = '<password>',
                                                  ssl = False,
                                                  virtual_host = 'rabbitvhost')  
channel =

name, jobs, consumers = channel.queue_declare(queue='queue_name', passive=True)

jobs # no of jobs in the queue
consumers # no of workers working on that queue

#Delete the queue

# Close the channel
# Close our connection
happy programming :)

No comments:

Post a Comment