(self, rmq_server)
Create PUB socket and bind
Create PUB socket and bind
Create PUB socket and bind
def _bind(self, rmq_server):
        """
           Create PUB socket and bind
        """
        if ((rmq_server in self.connections.keys() and
             self.connections[rmq_server] is not None and
             self.connections[rmq_server].is_open)):
            # It seems we already have this server, so let's try _unbind just
            # to be safe.
            self._unbind(rmq_server)

        credentials = None
        if self.rmq_user and self.rmq_password:
            credentials = pika.PlainCredentials(
                self.rmq_user,
                self.rmq_password)

        parameters = pika.ConnectionParameters(
            host=rmq_server,
            port=self.rmq_port,
            virtual_host=self.rmq_vhost,
            credentials=credentials,
            heartbeat_interval=self.rmq_heartbeat_interval,
            retry_delay=5,
            connection_attempts=3)

        self.connections[rmq_server] = None
        while (self.connections[rmq_server] is None or
               self.connections[rmq_server].is_open is False):
            try:
                self.connections[rmq_server] = pika.BlockingConnection(
                    parameters)
                self.channels[rmq_server] = self.connections[
                    rmq_server].channel()
                self.channels[rmq_server].exchange_declare(
                    exchange=self.rmq_exchange,
                    type=self.rmq_exchange_type,
                    durable=self.rmq_durable)
                # Reset reconnect_interval after a successful connection
                self.reconnect_interval = 1
            except Exception as exception:
                self.log.debug("Caught exception in _bind: %s", exception)
                if rmq_server in self.connections.keys():
                    self._unbind(rmq_server)

                if self.reconnect_interval >= 16:
                    break

                if self.reconnect_interval < 16:
                    self.reconnect_interval = self.reconnect_interval * 2

                time.sleep(self.reconnect_interval)
def _bind ( self , rmq_server ) : if ( ( rmq_server in self . connections . keys ( ) and self . connections [ rmq_server ] is not None and self . connections [ rmq_server ] . is_open ) ) : # It seems we already have this server, so let's try _unbind just # to be safe. self . _unbind ( rmq_server ) credentials = None if self . rmq_user and self . rmq_password : credentials = pika . PlainCredentials ( self . rmq_user , self . rmq_password ) parameters = pika . ConnectionParameters ( host = rmq_server , port = self . rmq_port , virtual_host = self . rmq_vhost , credentials = credentials , heartbeat_interval = self . rmq_heartbeat_interval , retry_delay = 5 , connection_attempts = 3 ) self . connections [ rmq_server ] = None while ( self . connections [ rmq_server ] is None or self . connections [ rmq_server ] . is_open is False ) : try : self . connections [ rmq_server ] = pika . BlockingConnection ( parameters ) self . channels [ rmq_server ] = self . connections [ rmq_server ] . channel ( ) self . channels [ rmq_server ] . exchange_declare ( exchange = self . rmq_exchange , type = self . rmq_exchange_type , durable = self . rmq_durable ) # Reset reconnect_interval after a successful connection self . reconnect_interval = 1 except Exception as exception : self . log . debug ( "Caught exception in _bind: %s" , exception ) if rmq_server in self . connections . keys ( ) : self . _unbind ( rmq_server ) if self . reconnect_interval >= 16 : break if self . reconnect_interval < 16 : self . reconnect_interval = self . reconnect_interval * 2 time . sleep ( self . reconnect_interval )