Getting the number of unacknowledged messages in the RabbitMQ queue from Java / Spring

is there any way to return the number of unacknowledged messages?

I use 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 also like to know the number of unrecognized messages.

I saw that the RabbitMQ Admin tool includes this information (for each queue it displays the number of Ready / Unacked and Total messages), and I guess there should be a way to get this from Java / Spring.

thanks

UPDATE

Oks, it seems that there is no way to execute this programmatically, as the configuration / queue list is not part of AMPQ.

It is possible to enable the management plugin and request REST web services for queues (among other things). More details here:

http://www.rabbitmq.com/management.html

+7
source share
1 answer

As you say in your update, if you enable the control plugin, you can request the rest of the api:

For example:

 `http://username: password@queue-server :15672/api/queues/%2f/queue_name.queue` 

This returns json (among other things)

  • messages_unacknowledged
  • messages_ready

This is good stuff if you have a safe route to the server.

+7
source

All Articles