Beispiel #1
0
 def listen_for_notifications(self, targets_and_priorities, pool):
     listener = pika_drv_poller.NotificationPikaPoller(
         self._pika_engine,
         targets_and_priorities,
         prefetch_count=(
             self._pika_engine.notification_listener_prefetch_count),
         queue_name=pool)
     listener.start()
     return listener
Beispiel #2
0
 def listen_for_notifications(self, targets_and_priorities, pool,
                              batch_size, batch_timeout):
     listener = pika_drv_poller.NotificationPikaPoller(
         self._pika_engine,
         targets_and_priorities,
         prefetch_count=(
             self._pika_engine.notification_listener_prefetch_count),
         queue_name=pool)
     listener.start()
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
    def test_declare_notification_queue_bindings_default_queue(
            self, pika_incoming_message_mock):
        poller = pika_poller.NotificationPikaPoller(
            self._pika_engine,
            self._target_and_priorities,
            None,
            self._prefetch_count,
        )
        self._poller_connection_mock.process_data_events.side_effect = (
            lambda time_limit: poller._on_message_with_ack_callback(
                None, None, None, None))

        poller.start()
        res = poller.poll()

        self.assertEqual(len(res), 1)

        self.assertEqual(res[0], pika_incoming_message_mock.return_value)

        self.assertTrue(self._pika_engine.create_connection.called)
        self.assertTrue(self._poller_connection_mock.channel.called)

        declare_queue_binding_by_channel_mock = (
            self._pika_engine.declare_queue_binding_by_channel)

        self.assertEqual(declare_queue_binding_by_channel_mock.call_count, 3)

        declare_queue_binding_by_channel_mock.assert_has_calls(
            (mock.call(channel=self._poller_channel_mock,
                       durable=self._pika_engine.notification_persistence,
                       exchange="exchange1",
                       exchange_type='direct',
                       queue="topic1.1",
                       queue_expiration=None,
                       routing_key="topic1.1"),
             mock.call(channel=self._poller_channel_mock,
                       durable=self._pika_engine.notification_persistence,
                       exchange="exchange1",
                       exchange_type='direct',
                       queue="topic1.2",
                       queue_expiration=None,
                       routing_key="topic1.2"),
             mock.call(channel=self._poller_channel_mock,
                       durable=self._pika_engine.notification_persistence,
                       exchange="exchange2",
                       exchange_type='direct',
                       queue="topic2.1",
                       queue_expiration=None,
                       routing_key="topic2.1")))
Beispiel #4
0
    def test_declare_notification_queue_bindings_custom_queue(self):
        poller = pika_poller.NotificationPikaPoller(
            self._pika_engine, self._target_and_priorities, 1, None,
            self._prefetch_count, "custom_queue_name")

        poller.start(None)

        self.assertTrue(self._pika_engine.create_connection.called)
        self.assertTrue(self._poller_connection_mock.channel.called)

        declare_queue_binding_by_channel_mock = (
            self._pika_engine.declare_queue_binding_by_channel)

        self.assertEqual(declare_queue_binding_by_channel_mock.call_count, 3)

        declare_queue_binding_by_channel_mock.assert_has_calls(
            (mock.call(channel=self._poller_channel_mock,
                       durable=self._pika_engine.notification_persistence,
                       exchange="exchange1",
                       exchange_type='direct',
                       queue="custom_queue_name",
                       queue_expiration=None,
                       routing_key="topic1.1"),
             mock.call(channel=self._poller_channel_mock,
                       durable=self._pika_engine.notification_persistence,
                       exchange="exchange1",
                       exchange_type='direct',
                       queue="custom_queue_name",
                       queue_expiration=None,
                       routing_key="topic1.2"),
             mock.call(channel=self._poller_channel_mock,
                       durable=self._pika_engine.notification_persistence,
                       exchange="exchange2",
                       exchange_type='direct',
                       queue="custom_queue_name",
                       queue_expiration=None,
                       routing_key="topic2.1")))
Beispiel #5
0
 def listen_for_notifications(self, targets_and_priorities, pool,
                              batch_size, batch_timeout):
     return pika_drv_poller.NotificationPikaPoller(
         self._pika_engine, targets_and_priorities, batch_size,
         batch_timeout,
         self._pika_engine.notification_listener_prefetch_count, pool)
Beispiel #6
0
 def listen_for_notifications(self, targets_and_priorities, pool):
     listener = pika_drv_poller.NotificationPikaPoller(
         self._pika_engine, targets_and_priorities, pool)
     listener.start()
     return listener