我有一个队列,多个消费者以循环方式工作。
Delivery_tag 用于在消费者完成处理后确认消息。但是多个消费者设置相同delivery_tag
,尽管他们正在处理的消息不同。
结果,当 acking 完成时,我得到了precondition failed
。
谁能建议我做错了什么?
这是消费者代码。我从这个链接得到它:
http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/
from amqplib import client_0_8 as amqp
conn = amqp.Connection(host="localhost:5672", userid="guest", password="guest", virtual_host="/", insist=False)
chan = conn.channel()
chan.queue_declare(queue="po_box", durable=True, exclusive=False, auto_delete=False)
chan.exchange_declare(exchange="sorting_room", type="direct", durable=True, auto_delete=False,)
chan.queue_bind(queue="po_box", exchange="sorting_room", routing_key="jason")
def recv_callback(msg):
print 'Received: ' + msg.body + ' from channel #' + str(msg.channel.channel_id)
chan.basic_consume(queue='po_box', no_ack=True, callback=recv_callback, consumer_tag="testtag")
while True:
chan.wait()
chan.basic_cancel("testtag")
chan.close()
conn.close()