From c881baed29db49c5710795496cb07907e35ceaba Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk <sileht@redhat.com> Date: Tue, 11 Oct 2016 18:03:32 +0200 Subject: [PATCH] rabbit: Don't prefetch when batch_size is set When the application set batch_size, so we don't need to prefetch more messages, especially for notifications. Notifications queues can be really big when the consumer have disapear during a long period, and when it come back, kombu/pyamqp will fetch all messages it can. So we override the qos prefetch value. Change-Id: I601e10cf94310b9f96f7acb9942959aaafad7994 Closes-bug: #1551667 --- oslo_messaging/_drivers/amqpdriver.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oslo_messaging/_drivers/amqpdriver.py b/oslo_messaging/_drivers/amqpdriver.py index f02159222..f555eafad 100644 --- a/oslo_messaging/_drivers/amqpdriver.py +++ b/oslo_messaging/_drivers/amqpdriver.py @@ -487,6 +487,12 @@ class AMQPDriverBase(base.BaseDriver): def listen_for_notifications(self, targets_and_priorities, pool, batch_size, batch_timeout): conn = self._get_connection(rpc_common.PURPOSE_LISTEN) + # NOTE(sileht): The application set batch_size, so we don't need to + # prefetch more messages, especially for notifications. Notifications + # queues can be really big when the consumer have disapear during a + # long period, and when it come back, kombu/pyamqp will fetch all + # messages it can. So we override the default qos prefetch value + conn.connection.rabbit_qos_prefetch_count = batch_size listener = AMQPListener(self, conn) for target, priority in targets_and_priorities: