0

我有一個隊列,其中多個消費者以循環方式工作。Rabbitmq Acking在多個消費者

Delivery_tag用於消費者完成其處理後的確認消息。但多個消費者設置相同delivery_tag,雖然他們正在工作的消息是不同的。

由於這樣做,當完成了,我得到precondition failed

任何人都可以建議我做錯了什麼?

這是消費者code.I得到它從這個鏈接:

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() 
+0

您可以發佈您的消費代碼? –

+0

僅供參考,您得到的消費者代碼是Python而不是Groovy。 –

+0

在給定的消費者代碼中沒有ack。 –

回答

0

這是消費者code.I得到它從這個鏈接。

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()