NACK on consumer failure

(imported from commit 1cad1096dd1a969b2551822575784c338a82f433)
This commit is contained in:
Luke Faraone
2013-10-17 16:52:45 -04:00
parent 9d4ef27b97
commit 1fa65915f2

View File

@@ -96,8 +96,12 @@ class SimpleQueueClient(object):
def register_consumer(self, queue_name, consumer):
def wrapped_consumer(ch, method, properties, body):
consumer(ch, method, properties, body)
ch.basic_ack(delivery_tag=method.delivery_tag)
try:
consumer(ch, method, properties, body)
ch.basic_ack(delivery_tag=method.delivery_tag)
except Exception, e:
ch.basic_nack(delivery_tag=method.delivery_tag)
raise e
self.consumers[queue_name].add(wrapped_consumer)
self.ensure_queue(queue_name,