Esempio n. 1
0
 def listen(self, target):
     listener = pika_drv_poller.RpcServicePikaPoller(
         self._pika_engine,
         target,
         prefetch_count=self._pika_engine.rpc_listener_prefetch_count)
     listener.start()
     return listener
Esempio n. 2
0
 def listen(self, target, batch_size, batch_timeout):
     listener = pika_drv_poller.RpcServicePikaPoller(
         self._pika_engine,
         target,
         prefetch_count=self._pika_engine.rpc_listener_prefetch_count)
     listener.start()
     return base.PollStyleListenerAdapter(listener, batch_size,
                                          batch_timeout)
Esempio n. 3
0
    def test_declare_rpc_queue_bindings(self, rpc_pika_incoming_message_mock):
        poller = pika_poller.RpcServicePikaPoller(self._pika_engine,
                                                  self._target, 1, None,
                                                  self._prefetch_count)

        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, 6)

        declare_queue_binding_by_channel_mock.assert_has_calls(
            (mock.call(channel=self._poller_channel_mock,
                       durable=False,
                       exchange="exchange",
                       exchange_type='direct',
                       queue="topic_None_True_False",
                       queue_expiration=12345,
                       routing_key="topic_None_True_False"),
             mock.call(channel=self._poller_channel_mock,
                       durable=False,
                       exchange="exchange",
                       exchange_type='direct',
                       queue="topic_server_True_False",
                       queue_expiration=12345,
                       routing_key="topic_server_True_False"),
             mock.call(channel=self._poller_channel_mock,
                       durable=False,
                       exchange="exchange",
                       exchange_type='direct',
                       queue="topic_server_True_True",
                       queue_expiration=12345,
                       routing_key="topic_all_workers_True_False"),
             mock.call(channel=self._poller_channel_mock,
                       durable=False,
                       exchange="exchange",
                       exchange_type='direct',
                       queue="topic_None_False_False",
                       queue_expiration=12345,
                       routing_key="topic_None_False_False"),
             mock.call(channel=self._poller_channel_mock,
                       durable=False,
                       exchange="exchange",
                       exchange_type='direct',
                       queue="topic_server_False_False",
                       queue_expiration=12345,
                       routing_key='topic_server_False_False'),
             mock.call(channel=self._poller_channel_mock,
                       durable=False,
                       exchange="exchange",
                       exchange_type='direct',
                       queue="topic_server_False_True",
                       queue_expiration=12345,
                       routing_key='topic_all_workers_False_False')))
Esempio n. 4
0
 def listen(self, target, batch_size, batch_timeout):
     return pika_drv_poller.RpcServicePikaPoller(
         self._pika_engine, target, batch_size, batch_timeout,
         self._pika_engine.rpc_listener_prefetch_count)
Esempio n. 5
0
    def test_declare_rpc_queue_bindings(self, rpc_pika_incoming_message_mock):
        poller = pika_poller.RpcServicePikaPoller(
            self._pika_engine,
            self._target,
            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], rpc_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, 6)

        declare_queue_binding_by_channel_mock.assert_has_calls((
            mock.call(channel=self._poller_channel_mock,
                      durable=False,
                      exchange="exchange_topic_False_True",
                      exchange_type='direct',
                      queue="topic_None_True",
                      queue_expiration=12345,
                      routing_key="topic_None_True"),
            mock.call(channel=self._poller_channel_mock,
                      durable=False,
                      exchange="exchange_topic_False_True",
                      exchange_type='direct',
                      queue="topic_server_True",
                      queue_expiration=12345,
                      routing_key="topic_server_True"),
            mock.call(channel=self._poller_channel_mock,
                      durable=False,
                      exchange="exchange_topic_True_True",
                      exchange_type='fanout',
                      queue="topic_server_True",
                      queue_expiration=12345,
                      routing_key=''),
            mock.call(channel=self._poller_channel_mock,
                      durable=False,
                      exchange="exchange_topic_False_False",
                      exchange_type='direct',
                      queue="topic_None_False",
                      queue_expiration=12345,
                      routing_key="topic_None_False"),
            mock.call(channel=self._poller_channel_mock,
                      durable=False,
                      exchange="exchange_topic_False_False",
                      exchange_type='direct',
                      queue="topic_server_False",
                      queue_expiration=12345,
                      routing_key="topic_server_False"),
            mock.call(channel=self._poller_channel_mock,
                      durable=False,
                      exchange="exchange_topic_True_False",
                      exchange_type='fanout',
                      queue="topic_server_False",
                      queue_expiration=12345,
                      routing_key=''),
        ))