我正在使用 txamqp python 库连接到 AMQP 代理(RabbitMQ),并且我有一个带有以下回调的消费者:
@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)
当“确认”一条消息时,它将从队列中删除(确认?),但是当消息没有“确认”时会发生什么?我需要一个“重试”机制,我可以推迟消息稍后再次回调,并跟踪它重试了多少次。
以及如何从队列中列出/删除消息?