mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 00:18:12 +00:00
NACK on consumer failure
(imported from commit 1cad1096dd1a969b2551822575784c338a82f433)
This commit is contained in:
@@ -96,8 +96,12 @@ class SimpleQueueClient(object):
|
|||||||
|
|
||||||
def register_consumer(self, queue_name, consumer):
|
def register_consumer(self, queue_name, consumer):
|
||||||
def wrapped_consumer(ch, method, properties, body):
|
def wrapped_consumer(ch, method, properties, body):
|
||||||
|
try:
|
||||||
consumer(ch, method, properties, body)
|
consumer(ch, method, properties, body)
|
||||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
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.consumers[queue_name].add(wrapped_consumer)
|
||||||
self.ensure_queue(queue_name,
|
self.ensure_queue(queue_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user