RabbitMQ 问题 记录

1. 如何确定一个队列是否为空?

http://rabbitmq.1065348.n5.nabble.com/check-if-queue-is-empty-td2129.html

1)
status = channel. queue_declare(queue=msgqueue)
if status.method.message_count == 0:
    print "queue empty"

2)

Mark,

On 21/09/11 15:30, Mark K wrote:
> I noticed one thing.... the
> status.method.message_count doesn't always match the number in the queue. For
> example I have a situation now where there is one message in the queue, and I
> can get an accurate count using the Rabbitmq api/queues but the status.method
> reports no messages in the same queue.

That's because queue.declare et al return
<quote>
[The] number of messages present in the queue [...] that are not
awaiting acknowledgement.

</quote>
(from the AMQP 0-9-1 spec xml)

whereas the 'messages' figure in rabbitmqctl and management includes
messages awaiting acknowledgement. You can get a breakdown with, e.g.,
   rabbitmqctl list_queues name messages_ready messages_unacknowledged
The messages_ready count should correspond to the count returned by the
AMQP commands.

Matthias.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值