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.
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.
I am 2 years too late but I was searching for it myself and found that rabbitmq gives u simple script to communicate to erlang nodes..its in sbin folder where the starting script for RabbitMQ is located..so you can basically say
this will display the queues along with the count of messages pending to those queues similarly you can also say
etc. For more info you can visit here
Update: it appears that the pika implementation of queue_declare(..) has changed since mmalone's very helpful post.
In python/pika (v0.9.5) it's still possible to check the queue depth via pika, but it requires a slightly more indirect approach.
queue_declare(...) passes a method object into its callback function, which you can then inspect. For example, to check the number of messages and consumers in the queue named
'myQueue'
:Hope this helps, and please go easy on me, I'm new around here :-)
You actually can retrieve this via the client. When perform a
queue_declare
operation RabbitMQ returns a three tuple containing(<queue name>, <message count>, <consumer count>)
. Thepassive
argument to queue_declare allows you to check whether a queue exists without modifying the server state. So you can usequeue_declare
with thepassive
option to check queue length. Not sure about .NET, but in Python it looks something like this:my little snippet based on Myydrralls' answer. I think if he had code in his answer I might have noticed it much quicker.
I'm using version 3.3.1 of the .Net Client Library.
I use the following, which is very similar to Ralph Willgoss second suggestion but you can supply the queue name as an argument.
If you wanted to do this in .Net, check which version of the Client library you are using.
I'm using the 2.2.0 version and I had to use BasicGet(queue, noAck).
In this version of the Library QueueDeclare() only returns a string containing the queue name.
I know from the 2.6.1 version, QueueDeclare() returns an object of type QueueDeclareOk.
Alternatively, you can call from the command line:
And you see the following output:
HTH