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.
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'
:
def cbInspect(qb):
messagesInQueue = qb.method.message_count
print "There are %d messages in myQueue" % messagesInQueue
consumersInQueue = qb.method.consumer_count
print "There are %d consumers in myQueue" % consumersInQueue
return
myChannel = channel.queue_declare(callback=cbInspect, queue='myQueue', passive=True)
Hope this helps, and please go easy on me, I'm new around here :-)