[rabbitmq-discuss] Reliable way to get number of messages in a queue

Matthew Sackman matthew at lshift.net
Wed Nov 18 17:52:06 GMT 2009


On Wed, Nov 18, 2009 at 05:18:53PM +0000, Matthew Sackman wrote:
> That's odd. However, you're really much much better off using
> queue.declare to redeclare the existing queue - the declare-ok that you
> get back contains the number of messages in the queue. This is a much
> neater strategy than below. I would recommend you switch to using this
> and repeat your test.

What's actually wrong with what you were doing is that the rabbitmqctl
list_queues contains both the ready messages and the unack'd msgs (as
well as uncommitted msgs). Thus if your consumers aren't acking msgs
quickly enough (and have an unbounded qos setting) then it will appear
that they're not keeping up. Use:

rabbitmqctl list_queues name messages_ready messages_unacknowledged

Matthew




More information about the rabbitmq-discuss mailing list