2012-08-29 58 views
3

我使用txamqp Python庫連接到AMQP代理(RabbitMQ的),我有以下的回調消費者:如何刪除或AMQP隊列推遲的消息

@defer.inlineCallbacks 
def message_callback(self, message, queue, chan): 
    """This callback is a queue listener 
    it is called whenever a message was consumed from queue 
    c.f. test_amqp.ConsumeTestCase for use cases 
    """ 

    # The callback should be redefined here to keep getting further messages from queue 
    queue.get().addCallback(self.message_callback, queue, chan).addErrback(self.message_errback)   

    print " [x] Received a valid message: [%r]" % (message.content.body,) 

    yield self.smpp.sendDataRequest(SubmitSmPDU) 

    # ACK the message in queue, this will remove it from the queue 
    chan.basic_ack(message.delivery_tag) 

當「ACK」荷蘭國際集團的消息,它將從隊列中刪除(確認?),但是當消息不是「ACK」版,會發生什麼?我需要得到一個「重試」的機制,我可以推遲到再後來就回呼的消息,並隨時跟蹤多少重試它採取。

而且我怎樣才能列出/從隊列中刪除郵件?

回答

0

已經解決了,爲了從隊列中重試消息,必須用'重試'標誌拒絕消息,它將被排隊回隊列。

如果我用定時器(callLater扭曲)拒絕它,消息排隊將被推遲,無論我想要什麼時間。

相關問題