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.
我已经看到RabbitMQ管理工具包含了这些信息(对于每个队列,它给出了Ready / Unacked和Total消息的数量),我想必须有一种从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.
Oks,似乎没有办法以编程方式完成,因为配置/队列的列表不是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:
可以启用管理插件并查询有关队列的REST Web服务(以及其他内容)。更多信息:
http://www.rabbitmq.com/management.html
1 个解决方案
#1
7
As you say in your update, if you enable the management plugin, you can query the rest api:
正如您在更新中所说,如果启用管理插件,您可以查询其余的api:
Eg:
`http://username:password@queue-server:15672/api/queues/%2f/queue_name.queue`
This returns json with (among other things)
这会返回json(除其他外)
- messages_unacknowledged
- messages_ready
It's good stuff if you have a safe route to the server.
如果你有一条通往服务器的安全路线,这是件好事。
#1
7
As you say in your update, if you enable the management plugin, you can query the rest api:
正如您在更新中所说,如果启用管理插件,您可以查询其余的api:
Eg:
`http://username:password@queue-server:15672/api/queues/%2f/queue_name.queue`
This returns json with (among other things)
这会返回json(除其他外)
- messages_unacknowledged
- messages_ready
It's good stuff if you have a safe route to the server.
如果你有一条通往服务器的安全路线,这是件好事。