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
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 = connection.channel()happy programming :)
name, jobs, consumers = channel.queue_declare(queue='queue_name', passive=True)
jobs # no of jobs in the queueconsumers # no of workers working on that queue
#Delete the queuechannel.queue_delete(queue='queue_name')
# Close the channel
channel.close()
# Close our connection
connection.close()
No comments:
Post a Comment