erlang 我可以通过AMQP客户端查看RabbitMQ中未确认消息的计数吗?

hjqgdpho  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(234)

In the RabbitMQ web UI, I can see, for each queue, the number of messages that are ready to be consumed and the number that are being processed but have not yet been acked.

However, I don't see how to get the number of unacked messages via an AMQP client.
For instance, the AMQP.Queue.message_count/2 function in the Elixir client uses the underlying Erlang library to re-declare the queue with passive: true and gets back message_count and consumer_count fields, but the message_count includes only messages that are "ready for delivery (e.g. not pending acknowledgements)".
My goal is to see how big a backlog of messages I currently have. For my purposes, those that are currently being processed are just as much a part of that as those that are ready for processing.
How can I get a count of unacked messages for a given RabbitMQ queue using an AMQP client?

eoxn13cs

eoxn13cs1#

AMQP 0.9-1在Declare-OK消息中没有该信息,我在RabbitMQ's AMQP extensions中也没有看到该信息。
如果使用者相似,则可以使用近似值Total = Ready + ConsumerCount * QoS(QoS是每个使用者的预取计数),考虑到如果Ready == 0,则近似值是上限(因为代理可能没有足够的消息来满足所有使用者)。
您还有另一个选择,即使用管理插件通过REST API

相关问题