从Java / Spring中检索RabbitMQ队列中未确认消息的数量 [英] Retrieving number of unacknowledged messages in RabbitMQ queue from Java/ Spring
问题描述
有没有办法返回未确认的消息数?
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.
我看到RabbitMQ管理工具包含了这些信息(对于每个队列,它给出了Ready / Unacked和Total消息的数量),我想必须有一种方法从Java /中检索它春天。
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.
谢谢
更新
Oks,似乎没有办法以编程方式完成,因为配置/队列的列表不是AMPQ的一部分。
Oks, it seems there is no way to accomplish that programmatically since listing of configuration/ queues is not part of AMPQ.
有可能启用管理插件并查询有关队列的REST Web服务(以及其他内容)。更多信息:
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
推荐答案
正如您在更新中所述,如果您启用了管理插件,你可以查询其余的api:
As you say in your update, if you enable the management plugin, you can query the rest api:
例如:
`http://username:password@queue-server:15672/api/queues/%2f/queue_name.queue`
这会返回json(除其他外)
This returns json with (among other things)
- messages_unacknowledged
- messages_ready
如果您有到服务器的安全路线,这是件好事。
It's good stuff if you have a safe route to the server.
这篇关于从Java / Spring中检索RabbitMQ队列中未确认消息的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!