Check RabbitMQ queue size from client

后端 未结 9 1110
终归单人心
终归单人心 2021-01-30 20:12

Does anyone know if there\'s a way to check the number of messages in a RabbitMQ queue from a client application?

I\'m using the .NET client library.

9条回答
  •  清歌不尽
    2021-01-30 21:04

    I was able to get the size/depth of queue from python program. 1. using py_rabbit

        from pyrabbit.api import Client
        cl = Client('10.111.123.54:15672', 'userid', 'password',5)
        depth = cl.get_queue_depth('vhost', 'queue_name')
    
    1. kombu [a python package usually comes with celery installation]
    conn = kombu.Connection('amqp://userid:password@10.111.123.54:5672/vhost')
    conn.connect()
    client = conn.get_manager()
    queues = client.get_queues('vhost')
    for queue in queues:
        if queue == queue_name:
        print("tasks waiting in queue:"+str(queue.get("messages_ready")))
        print("tasks currently running:"+str(queue.get("messages_unacknowledged")))
    
    

    the ip address is just an example.

提交回复
热议问题