From e0eeca6706a873b90f895674af2b00e6dd57ae69 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Wed, 11 Oct 2017 18:19:07 +0300 Subject: [PATCH] [Event-engine] Make listener pool name configurable * Now it is impossible to set the same pool name for queue listeners which use event engine. By default, it creates an unique pool named so each event engine is in its own pool. Due to that and documentation of oslo.messaging, any message that comes to topic duplicates across all event engines. * But if they have the same pool name, the message will be delivered only to one of event-engines (by round-robin). * This patch adds a possibility to change listener pool name for each event-engine. Change-Id: Iea83c461694a26d9cea810e6cc6169a0fe3f9f06 --- mistral/config.py | 7 +++++++ mistral/messaging.py | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mistral/config.py b/mistral/config.py index c4d04fbe9..58f291e79 100644 --- a/mistral/config.py +++ b/mistral/config.py @@ -227,6 +227,13 @@ event_engine_opts = [ 'identifier. It is not necessarily a hostname, ' 'FQDN, or IP address.') ), + cfg.HostAddressOpt( + 'listener_pool_name', + default='events', + help=_('Name of the event engine\'s listener pool. This can be an' + ' opaque identifier. It is used for identifying the group' + ' of event engine listeners in oslo.messaging.') + ), cfg.StrOpt( 'topic', default='mistral_event_engine', diff --git a/mistral/messaging.py b/mistral/messaging.py index 4707505e9..4e8b68408 100644 --- a/mistral/messaging.py +++ b/mistral/messaging.py @@ -18,8 +18,8 @@ AMQP messages based on olso.messaging framework. """ import abc -import socket +from oslo_config import cfg from oslo_log import log as logging import oslo_messaging from oslo_messaging.notify import dispatcher @@ -30,6 +30,7 @@ from oslo_utils import timeutils import six LOG = logging.getLogger(__name__) +CONF = cfg.CONF def handle_event(self, ctxt, publisher_id, event_type, payload, metadata): @@ -91,7 +92,8 @@ def get_pool_name(exchange): :param exchange: exchange name """ - pool_name = 'mistral-%s-%s' % (exchange, socket.gethostname()) + pool_host = CONF.event_engine.listener_pool_name + pool_name = 'mistral-%s-%s' % (exchange, pool_host) LOG.debug("Listener pool name is %s", pool_name)