How to use the pika.SelectConnection function in pika

To help you get started, we’ve selected a few pika examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Bluefissure / FFXIVBOT / ffxivbot / pika_rabbit.py View on Github external
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)
        parameters = pika.URLParameters(self._url)

        return pika.SelectConnection(
            parameters, self.on_connection_open, stop_ioloop_on_close=False
        )
github VOLTTRON / volttron / volttron / platform / vip / rmq_connection.py View on Github external
def open_connection(self):
        """
        Open asynchronous connection for router/platform
        :return:
        """
        self._connection = pika.SelectConnection(self._connection_param,
                                                 on_open_callback=self.on_connection_open,
                                                 on_close_callback=self.on_connection_closed,
                                                 on_open_error_callback=self.on_open_error,
                                                 stop_ioloop_on_close=False
                                                 )
github apache / airavata / sandbox / simstream / simstream / pikaasyncconsumer.py View on Github external
def connect(self):
        """
        Create an asynchronous connection to the RabbitMQ server at URL.
        """
        return pika.SelectConnection(pika.URLParameters(self._url),
                                     on_open_callback=self.on_connection_open,
                                     on_close_callback=self.on_connection_close,
                                     stop_ioloop_on_close=False)
github dune-universe / dune-universe / packages / amqp-client.2.0.2 / other / pika_async.py View on Github external
def connect(self):
        LOGGER.info('Connecting to %s', self._url)
        return pika.SelectConnection(pika.URLParameters(self._url),
                                     self.on_connection_open,
                                     stop_ioloop_on_close=False)
github studioml / studio / studio / rabbit_queue.py View on Github external
def connect(self):
        """
        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

        """
        return pika.SelectConnection(
            pika.URLParameters(
                self._url),
            on_open_callback=self.on_connection_open,
            on_close_callback=self.on_connection_closed,
            stop_ioloop_on_close=False)
github pika / pika / examples / asynchronous_consumer_example.py View on Github external
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 pika.SelectConnection(
            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)
github metaspace2020 / metaspace / metaspace / engine / sm / engine / queue.py View on Github external
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

        """
        self.logger.info('Connecting to %s', self._url)
        return pika.SelectConnection(
            pika.URLParameters(self._url), self.on_connection_open, stop_ioloop_on_close=False
        )
github fedora-infra / fedora-messaging / fedora_messaging / _session.py View on Github external
def connect(self):
        _log.info("Connecting to %s:%d", self._parameters.host, self._parameters.port)
        self._connection = pika.SelectConnection(
            self._parameters,
            on_open_callback=self._on_connection_open,
            on_open_error_callback=self._on_connection_error,
            on_close_callback=self._on_connection_close,
        )
github ttrifonov / EventBrain / src / eventbrain / contrib / rabbitmq / pika_wrapper.py View on Github external
self.on_receive(self.channel_id, method_frame, header_frame, body)

        self.host = kwargs.get('host', "localhost")
        self.vhost = kwargs.get("vhost", "/")
        params = pika.ConnectionParameters(host=self.host,
                                           virtual_host=self.vhost)
        if "user" in kwargs.keys() and "password" in kwargs.keys():
            self.user = kwargs['user']
            self.password = kwargs['password']
            credentials = pika.PlainCredentials(self.user, self.password)
            params.credentials = credentials

        self.params = params

        reconnect = pika.reconnection_strategies.SimpleReconnectionStrategy()
        self.connection = pika.SelectConnection(params,
                                            on_open_callback=on_connected,
                                            reconnection_strategy=reconnect)
        #self.connection.add_on_close_callback(on_closed)
        self.connection.add_backpressure_callback(on_backpressure)