Get queue length using Celery (RabbitMQ, Django)

I am using Celery in a django project, my broker is RabbitMQ and I want to get the length of the queues. I went through the Celery code, but did not find a tool for this. I found this problem in stackoverflow ( Check the size of the RabbitMQ queue from the client ), but I do not find it satisfactory.

Everything is set in celery, so there must be some kind of magical method to get what I want without specifying a channel / connection.

Does anyone know about this issue?

Thank!

+7
django queue celery rabbitmq django-celery
Jul 25 '13 at 16:24
source share
3 answers

PyRabbit is probably what you are looking for is the Python interface for the RabbitMQ management interface API. This will allow you to query the queues and their current messages.

+2
Jul 26 '13 at 11:14
source share

Here is an example of how to read the queue length in rabbitMQ for a given queue:

def get_rabbitmq_queue_length(q): from pyrabbit.api import Client from pyrabbit.http import HTTPError count = 0 try: cl = Client('localhost:15672', 'guest', 'guest') if cl.is_alive(): count = cl.get_queue_depth('/', q) except HTTPError as e: print "Exception: Could not establish to rabbitmq http api: " + str(e) + " Check for port, proxy, username/pass configuration errors" raise return count 

It uses pyrabbit as previously suggested by Philip

+2
Aug 30 '16 at 14:20
source share

You can inspect celery workers with the inspect module. Here is the guide .

There is also a command line command for RabbitMQ .

0
Jul 25 '13 at 16:53
source share



All Articles