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 _create_connection(self, topic, host): # Create a connection for rpc usage if (self.connected): return self.conn = rpc.create_connection(new=True) LOG.debug(_("Creating Consumer connection for Service %s") % topic) # Share this same connection for these Consumers self.conn.create_consumer(topic, self, fanout=False) node_topic = '%s.%s' % (topic, host) self.conn.create_consumer(node_topic, self, fanout=False) self.conn.create_consumer(topic, self, fanout=True) # Consume from all consumers in a thread self.conn.consume_in_thread()