[rabbitmq-discuss] check if queue is empty?

Matthias Radestock matthias at rabbitmq.com
Wed Sep 21 15:44:04 BST 2011


On 21/09/11 15:30, Mark K wrote:
> I noticed one thing.... the
> status.method.message_count doesn't always match the number in the queue. For
> example I have a situation now where there is one message in the queue, and I
> can get an accurate count using the Rabbitmq api/queues but the status.method
> reports no messages in the same queue.

That's because queue.declare et al return
[The] number of messages present in the queue [...] that are not 
awaiting acknowledgement.
(from the AMQP 0-9-1 spec xml)

whereas the 'messages' figure in rabbitmqctl and management includes 
messages awaiting acknowledgement. You can get a breakdown with, e.g.,
   rabbitmqctl list_queues name messages_ready messages_unacknowledged
The messages_ready count should correspond to the count returned by the 
AMQP commands.


More information about the rabbitmq-discuss mailing list