java 读取rabbitmq,从java代码获取rabbitmq队列中的消息计数(Getting count of messages in a rabbitmq queue from java co...

由于直接通过SDK获取rabbitmq队列消息计数不准确,可以启用管理插件并通过REST API获取详细信息。响应包含总消息数、处理中和就绪状态的消息数。例如,本地服务器响应显示了消息的各种状态和统计信息。
摘要由CSDN通过智能技术生成

you cannot get messages count using the SDK. channel.queueDeclarePassive(queueName).getMessageCount() is usually not correct because it won't count messages which waiting acknowledges.

you can enable the management plugin and query the queue by REST API:

http://localhost:15672/api/queues/vhost/queue_name

The response contains the total messages count as well as messages in handling/ready state. Access to "localhost:15672/api" to see more detail about how to call it.

Here is an example response of it on local server:

{

"memory":14680,

"message_stats":{

"publish":1,

"publish_details":{

"rate":0

}

},

"messages":1,

"messages_details":{

"rate":0

},

"messages_ready":1,

"messages_r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值