Retrieving number of unacknowledged messages in RabbitMQ queue from Java/ Spring
amqp, java, rabbitmq, spring, spring-amqp
Solution
As you say in your update, if you enable the management plugin, you can query the rest api:
Eg:
`http://username:password@queue-server:15672/api/queues/%2f/queue_name.queue`
This returns json with (among other things)
- messages_unacknowledged
- messages_ready
It's good stuff if you have a safe route to the server.
Problem
is there any way to return the number of messages that are unacknowledged? I am using this code to get the number of messages in the queue: ``` DeclareOk declareOk = amqpAdmin.getRabbitTemplate().execute( new ChannelCallback<DeclareOk>() { public DeclareOk doInRabbit(Channel channel) throws Exception { return channel.queueDeclarePassive(name); } }); return declareOk.getMessageCount(); ``` but I would like to know as well the number of unacknowledged messages. I have seen that the RabbitMQ Admin tool includes that information (for each queue it gives out the number of Ready/ Unacked and Total messages) and I guess there must be a way to retrieve that from Java/ Spring. Thanks UPDATE Oks, it seems there is no way to accomplish that programmatically since listing of configuration/ queues is not part of AMPQ. There is the possibility to enable the management plugin and query the REST web services about the queues (among other things). More info here: http://www.rabbitmq.com/management.html