listener_service - enable listen to multiple topics + specify exchange name
Change-Id: I689c3bd3f39ed38c86710341b3778b11f9e48f68
This commit is contained in:
parent
a54d1425b8
commit
0604e5ef1c
@ -45,9 +45,13 @@ OPTS = [
|
||||
min=1,
|
||||
help='Time to wait until retrying to snapshot the datasource'
|
||||
' in case of fault'),
|
||||
cfg.StrOpt('notification_topic',
|
||||
default='vitrage_notifications',
|
||||
help='Vitrage configured notifications topic'),
|
||||
cfg.ListOpt('notification_topics',
|
||||
default=['vitrage_notifications'],
|
||||
help='Vitrage configured notifications topic',
|
||||
deprecated_name='notification_topic'),
|
||||
cfg.StrOpt('notification_exchange',
|
||||
required=False,
|
||||
help='Exchange that is used for notifications.'),
|
||||
cfg.StrOpt('notification_topic_collector',
|
||||
default='vitrage_collector_notifications',
|
||||
help='The topic on which event will be sent from the '
|
||||
|
@ -33,8 +33,10 @@ class ListenerService(os_service.Service):
|
||||
self.enrich_callbacks_by_events = \
|
||||
self._create_callbacks_by_events_dict(drivers, conf)
|
||||
|
||||
topic = conf.datasources.notification_topic
|
||||
self.listener = self._get_topic_listener(conf, topic, callback)
|
||||
topics = conf.datasources.notification_topics
|
||||
exchange = conf.datasources.notification_exchange
|
||||
self.listener = self._get_topics_listener(
|
||||
conf, topics, callback, exchange)
|
||||
|
||||
def start(self):
|
||||
LOG.info("Vitrage data source Listener Service - Starting...")
|
||||
@ -65,10 +67,11 @@ class ListenerService(os_service.Service):
|
||||
|
||||
return ret
|
||||
|
||||
def _get_topic_listener(self, conf, topic, callback):
|
||||
def _get_topics_listener(self, conf, topics, callback, exchange=None):
|
||||
# Create a listener for each topic
|
||||
transport = messaging.get_transport(conf)
|
||||
targets = [oslo_messaging.Target(topic=topic)]
|
||||
targets = [oslo_messaging.Target(exchange=exchange, topic=topic)
|
||||
for topic in topics]
|
||||
|
||||
return messaging.get_notification_listener(
|
||||
transport,
|
||||
|
Loading…
Reference in New Issue
Block a user