def start(self): super(Service, self).start() self.conn = rpc.create_connection(new=True) LOG.debug(_("Creating Consumer connection for Service %s") % self.topic) dispatcher = rpc_dispatcher.RpcDispatcher([self.manager], self.serializer) # Share this same connection for these Consumers self.conn.create_consumer(self.topic, dispatcher, fanout=False) node_topic = '%s.%s' % (self.topic, self.host) self.conn.create_consumer(node_topic, dispatcher, fanout=False) self.conn.create_consumer(self.topic, dispatcher, fanout=True) # Hook to allow the manager to do other initializations after # the rpc connection is created. if callable(getattr(self.manager, 'initialize_service_hook', None)): self.manager.initialize_service_hook(self) # Consume from all consumers in a thread self.conn.consume_in_thread()
def test_mnb_connection(): # Because the oslo notifier code does not have a return status # and exceptions are caught inside oslo (I know...), the best we # can do here is use the oslo rpc code to try a test connection # to the MnB servers before the notification(s) are sent. connected = False try: cx = rpc.create_connection() cx.close() LOG.info("Verified RPC connection is ready") connected = True except rpc_common.RPCException as e: LOG.error("RPC connect exception: %s", e) except Exception as e: LOG.error("Non-RPC connect exception: %s", e) return connected