def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ LOGGER.info('Connecting to %s', self._amqp_dict) LOGGER.info(self) print(self.on_connection_open) print() try: credentials = pika.PlainCredentials( self._amqp_dict.get("user_name"), self._amqp_dict.get("password")) param = pika.ConnectionParameters(host=self._amqp_dict.get("host"), port=self._amqp_dict.get("port"), virtual_host='/', credentials=credentials) return adapters.TornadoConnection( parameters=param, on_open_callback=self.on_connection_open, on_open_error_callback=self.on_connection_open_error) except TabError as e: print(e)
def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection == established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ self.logger.info('Connecting to %s', self._url) # amqp://user2:[email protected]:5672/videos # _, info = self._url.split('amqp://') # info, vhost = info.split('/') # user, server = info.split('@') # username, password = user.split(':') # host, port = server.split(':') # cred = pika.PlainCredentials(username, password) # param = pika.ConnectionParameters( # host=host, # port=int(port), # virtual_host=vhost, # credentials=cred # ) param = pika.URLParameters(self._url) self._connection = adapters.TornadoConnection(param, self.on_connection_open)
def connect(self): parameters = pika.URLParameters(self.amqp_url) if (self.tornado_connector): self.connection = adapters.TornadoConnection( parameters, on_open_callback=self.on_connected) else: self.connection = pika.SelectConnection(parameters, self.on_connected, stop_ioloop_on_close=False)
def connect(self): """步骤1:连接到队列""" LOGGER.info('Connecting to %s', self._url) self._connection = adapters.TornadoConnection( parameters=pika.URLParameters(self._url), on_open_callback=self.on_connection_open, on_open_error_callback=self.on_open_error_callback, on_close_callback=self.on_connection_closed, )
def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ LOGGER.info('Connecting to RabbitMQ') return adapters.TornadoConnection(self.parameters, self.on_connection_open)
def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ logger.info('Connecting to %s', self._url) return adapters.TornadoConnection(pika.URLParameters(self._url), self.on_connection_open)
def connect(self, *args, **kwargs): """ This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ LOGGER.debug('Connecting to %s', self._url) LOGGER.debug('Got arguments: %r %r', args, kwargs) conn = adapters.TornadoConnection(pika.URLParameters(self._url), self.on_connection_open) self._connection = conn return conn
def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. If you want the reconnection to work, make sure you set stop_ioloop_on_close to False, which is not the default behavior of this adapter. :rtype: pika.SelectConnection """ LOGGER.info('Connecting to %s', self._url) return adapters.TornadoConnection(pika.URLParameters(self._url), self.on_connection_open, stop_ioloop_on_close=False)
def connect(self): try: # logger = logging.getLogger('rmq_tornado') # credentials = pika.PlainCredentials(RMQ_USER, RMQ_PWD) # param = pika.ConnectionParameters(host=RMQ_HOST, port=RMQ_PORT, credentials=credentials) # param = pika.URLParameters("amqp://*****:*****@223.202.203.118:5672/%2F?connection_attempts=3&heartbeat_interval=3600") rabbit_server = config.get('rabbitmq', 'host') amqp_url = "amqp://*****:*****@{0}/%2F?connection_attempts=3&heartbeat_interval=3600".format( rabbit_server) param = pika.URLParameters(amqp_url) # self.connection = TornadoConnection(param, on_open_callback=self.on_connected) self.connection = adapters.TornadoConnection(param, self.on_connected) except Exception as e: logger.error('Something went wrong... %s', e)
def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ # gen_log.info('Connecting to %s', self._url) cred = pika.PlainCredentials('guest', 'guest') param = pika.ConnectionParameters( host=self.rabbitmq_address, # port=5672, virtual_host='/', credentials=cred) return adapters.TornadoConnection(param, self.on_connection_open)
def connect(self): """This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. Publisher may be created **before** the IOLoop init, so TornadoConnection.ioloop should be IOLoop.instance() (as default value). if it's IOLoop.current(), the IOLoop will not execute the callback function. :rtype: pika.SelectConnection """ if self.connecting is False: app_log.info('正在连接MQ: %s', self._url) self.connecting = True self._connection = adapters.TornadoConnection( parameters=pika.URLParameters(self._url), on_open_callback=self.on_connection_open, on_open_error_callback=self.on_connection_open_error_callback) else: app_log.info('another connection is making MQ: %s', self._url) return
def connect(self): LOGGER.info('Connecting to %s', self.url) return adapters.TornadoConnection(self.params, self.on_connection_open)
def connect(self): return adapters.TornadoConnection(pika.URLParameters(self._url), self.on_connection_open)
def connect(self): self._connection = adapters.TornadoConnection( pika.URLParameters(self._url), self.on_connected)
def connect(self): LOG.info('Connecting to %s', self._url) return adapters.TornadoConnection(pika.URLParameters(self._url), self.on_connection_open, self.on_connection_open_error)
def connect(self): return adapters.TornadoConnection(pika.URLParameters(self.amqp_url))
def _connect(self): self._connection = adapters.TornadoConnection(parameters=pika.URLParameters(self._url), on_open_callback=self.__on_connection_open, on_open_error_callback=self.__on_connection_open_error, on_close_callback=self.__on_connection_closed)