Check RabbitMQ queue size from client

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

./rabbitmqctl list_queues

this will display the queues along with the count of messages pending to those queues similarly you can also say

./rabbitmqctl list_channels
./rabbitmqctl list_connections

etc. For more info you can visit here


I'm using version 3.3.1 of the .NET client library.

I use the following, which is very similar to Ralph Willgoss's second suggestion, but you can supply the queue name as an argument.

QueueDeclareOk result = channel.QueueDeclarePassive(queueName);
uint count = result != null ? result.MessageCount : 0;

If you want 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.

BasicGetResult result = channel.BasicGet("QueueName", false);
uint count = result != null ? result.MessageCount : 0;

I know from the 2.6.1 version, QueueDeclare() returns an object of type QueueDeclareOk.

QueueDeclareOk result = channel.QueueDeclare();
uint count = result.MessageCount;

Alternatively, you can call from the command line:

<InstallPathToRabbitMq>\sbin\rabbitmqctl.bat list_queues

And you see the following output:

Listing queues...
QueueName 1
...done.


You can actually retrieve this via the client.

When you perform a queue_declare operation, RabbitMQ returns a tuple with three values: (<queue name>, <message count>, <consumer count>). 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)