本文整理匯總了Python中oslo_messaging.get_notification_listener方法的典型用法代碼示例。如果您正苦於以下問題:Python oslo_messaging.get_notification_listener方法的具體用法?Python oslo_messaging.get_notification_listener怎麽用?Python oslo_messaging.get_notification_listener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oslo_messaging
的用法示例。
在下文中一共展示了oslo_messaging.get_notification_listener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def main():
if len(sys.argv) < 2:
print("Supply an exchange")
sys.exit(0)
exchange = sys.argv[1]
pool = sys.argv[2] if len(sys.argv) > 2 else None
transport = oslo_messaging.get_notification_transport(
cfg.CONF,
url='rabbit://%s:%s@%s' % (username, password, host))
targets = [oslo_messaging.Target(topic=topic, exchange=exchange)]
endpoints = [EP()]
oslo_listener = oslo_messaging.get_notification_listener(
transport, targets, endpoints, pool=pool, executor='threading')
try:
print("Started")
oslo_listener.start()
while True:
time.sleep(1)
except KeyboardInterrupt:
print("Stopping")
oslo_listener.stop()
oslo_listener.wait()
示例2: start
# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def start(self):
super(ListenerService, self).start()
transport = oslo_messaging.get_notification_transport(CONF)
targets = [
oslo_messaging.Target(topic=pl_topic, exchange=pl_exchange)
for pl_topic, pl_exchange in self.topics_exchanges_set
]
endpoints = [
NotificationEndpoint(self.plugins, PipelineManager(self.plugins))
]
listener = oslo_messaging.get_notification_listener(
transport,
targets,
endpoints,
executor='threading',
pool=CONF.listener.notifications_pool)
listener.start()
self.listeners.append(listener)
示例3: get_notification_listener
# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def get_notification_listener(targets, endpoints, serializer=None, pool=None):
if NOTIFICATION_TRANSPORT is None:
raise AssertionError("'NOTIFICATION_TRANSPORT' must not be None")
if serializer is None:
serializer = JsonPayloadSerializer()
return messaging.get_notification_listener(
NOTIFICATION_TRANSPORT,
targets,
endpoints,
executor='eventlet',
pool=pool,
serializer=serializer
)
示例4: get_notification_listener
# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def get_notification_listener(transport, targets, endpoints,
allow_requeue=False):
"""Return a configured oslo_messaging notification listener."""
return oslo_msg.get_notification_listener(
transport, targets, endpoints, allow_requeue=allow_requeue)
示例5: build_notification_handler
# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def build_notification_handler(self, topic_names, endpoints=()):
serializer = rpc.RequestContextSerializer(rpc.JsonPayloadSerializer())
targets = []
for topic in topic_names:
kwargs = {}
if '.' in topic:
exchange, topic = topic.split('.')
kwargs['exchange'] = exchange
kwargs['topic'] = topic
targets.append(om.Target(**kwargs))
return om.get_notification_listener(
self.notification_transport, targets, endpoints,
executor='eventlet', serializer=serializer,
allow_requeue=False, pool=CONF.host)
示例6: ListenerProc
# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def ListenerProc(exchange, project_id, cluster_id, recover_action):
"""Thread procedure for running an event listener.
:param exchange: The control exchange for a target service.
:param project_id: The ID of the project to filter.
:param cluster_id: The ID of the cluster to filter.
:param recover_action: The health policy action name.
"""
transport = messaging.get_notification_transport(cfg.CONF)
if exchange == cfg.CONF.health_manager.nova_control_exchange:
endpoint = nova_endpoint.NovaNotificationEndpoint(
project_id, cluster_id, recover_action
)
else:
endpoint = heat_endpoint.HeatNotificationEndpoint(
project_id, cluster_id, recover_action
)
listener = messaging.get_notification_listener(
transport, [endpoint.target], [endpoint], executor='threading',
pool='senlin-listeners'
)
listener.start()