def start(self): vcs_string = version.version_string_with_vcs() LOG.info(_('Starting %(topic)s node (version %(vcs_string)s)'), {'topic': self.topic, 'vcs_string': vcs_string}) self.conn = rpc.create_connection(new=True) LOG.debug(_("Creating Consumer connection for Service %s") % self.topic) # Share this same connection for these Consumers self.conn.create_consumer(self.topic, self, fanout=False) node_topic = '%s.%s' % (self.topic, self.host) self.conn.create_consumer(node_topic, self, fanout=False) self.conn.create_consumer(self.topic, self, fanout=True) # Consume from all consumers in a thread self.conn.consume_in_thread() if self.report_interval: pulse = utils.LoopingCall(self.report_state) pulse.start(interval=self.report_interval, now=False) self.timers.append(pulse) if self.periodic_interval: periodic = utils.LoopingCall(self.periodic_tasks) periodic.start(interval=self.periodic_interval, now=False) self.timers.append(periodic)
def start(self): vcs_string = version.version_string_with_vcs() LOG.info(_('Starting %(topic)s node (version %(vcs_string)s)'), {'topic': self.topic, 'vcs_string': vcs_string}) self.conn = rpc.create_connection(new=True) LOG.debug(_("Creating Consumer connection for Service %s") % self.topic) # Share this same connection for these Consumers self.conn.create_consumer(self.topic, self, fanout=False) node_topic = '%s.%s' % (self.topic, self.host) self.conn.create_consumer(node_topic, self, fanout=False) self.conn.create_consumer(self.topic, self, fanout=True) # Consume from all consumers in a thread self.conn.consume_in_thread() if self.report_interval: pulse = utils.LoopingCall(self.report_state) pulse.start(interval=self.report_interval, now=False) self.timers.append(pulse) if self.periodic_interval: periodic = utils.LoopingCall(self.periodic_tasks) periodic.start(interval=self.periodic_interval, now=False) self.timers.append(periodic)
def delete_queue(context, topic): if CONF.rpc_backend == "reddwarf.openstack.common.rpc.impl_kombu": connection = openstack_rpc.create_connection() channel = connection.channel durable = connection.conf.rabbit_durable_queues queue = kombu.entity.Queue(name=topic, channel=channel, auto_delete=False, exclusive=False, durable=durable) queue.delete()
def delete_queue(context, topic): if CONF.rpc_backend == "reddwarf.openstack.common.rpc.impl_kombu": connection = openstack_rpc.create_connection() channel = connection.channel durable = connection.conf.rabbit_durable_queues queue = kombu.entity.Queue(name=topic, channel=channel, auto_delete=False, exclusive=False, durable=durable) queue.delete()
def _cast_with_consumer(self, method_name, **kwargs): try: conn = rpc.create_connection(new=True) conn.create_consumer(self._get_routing_key(), None, fanout=False) except Exception as e: LOG.error(e) raise exception.GuestError(original_message=str(e)) finally: if conn: conn.close() # leave the cast call out of the hackity consumer create self._cast(method_name, **kwargs)
def _cast_with_consumer(self, method_name, **kwargs): try: conn = rpc.create_connection(new=True) conn.create_consumer(self._get_routing_key(), None, fanout=False) except Exception as e: LOG.error(e) raise exception.GuestError(original_message=str(e)) finally: if conn: conn.close() # leave the cast call out of the hackity consumer create self._cast(method_name, **kwargs)
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]) # 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 declare_queue(self, topic): """Call this to declare a queue from Python.""" #from reddwarf.rpc.impl_kombu import Connection from reddwarf.openstack.common.rpc import create_connection with create_connection() as conn: consumer = conn.declare_topic_consumer(topic=topic)