Check RabbitMQ queue size from client

后端 未结 9 1108
终归单人心
终归单人心 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:11

    You can actually retrieve this via the client.

    When you perform a queue_declare operation, RabbitMQ returns a tuple with three values: (, , ). The passive argument to queue_declare allows you to check whether a queue exists without modifying the server state, so you can use queue_declare with the passive option to check the queue length.

    Not sure about .NET, but in Python, it looks something like this:

    name, jobs, consumers = chan.queue_declare(queue=queuename, passive=True)
    

提交回复
热议问题