您的位置:首页 > 其它

RabbitMQ 问题 记录

2012-10-08 03:01 183 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: