From e785a5d994456bde3dec3843798cc65d411eb103 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Wed, 11 Dec 2013 16:50:09 +0100 Subject: [PATCH] Make the dispatcher responsible of the message ack This patch make the dispatcher responsible of the message acknowledgement. This is the preliminar step to be able to requeue message. Partial implements blueprint notification-subscriber-server Change-Id: If74b47d5e23976d407deb27df7395b1982963c75 --- oslo/messaging/_drivers/amqpdriver.py | 4 +--- oslo/messaging/notify/dispatcher.py | 1 + oslo/messaging/rpc/dispatcher.py | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oslo/messaging/_drivers/amqpdriver.py b/oslo/messaging/_drivers/amqpdriver.py index 158248883..1b1cac494 100644 --- a/oslo/messaging/_drivers/amqpdriver.py +++ b/oslo/messaging/_drivers/amqpdriver.py @@ -90,9 +90,7 @@ class AMQPListener(base.Listener): def poll(self): while True: if self.incoming: - message = self.incoming.pop(0) - message.acknowledge() - return message + return self.incoming.pop(0) self.conn.consume(limit=1) diff --git a/oslo/messaging/notify/dispatcher.py b/oslo/messaging/notify/dispatcher.py index a79cc29e8..1bcf84c93 100644 --- a/oslo/messaging/notify/dispatcher.py +++ b/oslo/messaging/notify/dispatcher.py @@ -60,6 +60,7 @@ class NotificationDispatcher(object): @contextlib.contextmanager def __call__(self, incoming): yield lambda: self._dispatch_and_handle_error(incoming) + incoming.acknowledge() def _dispatch_and_handle_error(self, incoming): """Dispatch a notification message to the appropriate endpoint method. diff --git a/oslo/messaging/rpc/dispatcher.py b/oslo/messaging/rpc/dispatcher.py index ecb1e8795..b9d114f87 100644 --- a/oslo/messaging/rpc/dispatcher.py +++ b/oslo/messaging/rpc/dispatcher.py @@ -124,6 +124,7 @@ class RPCDispatcher(object): @contextlib.contextmanager def __call__(self, incoming): + incoming.acknowledge() yield lambda: self._dispatch_and_reply(incoming) def _dispatch_and_reply(self, incoming):