def test_unexpected_correlation_id(container_factory, rabbit_config): container = container_factory(FooService, rabbit_config) container.start() with ServiceRpcProxy("foobar", rabbit_config) as proxy: message = Message(channel=None, properties={ 'reply_to': proxy.reply_listener.routing_key, 'correlation_id': 'invalid', }) amqp_uri = container.config['AMQP_URI'] exchange = get_rpc_exchange(container.config) responder = Responder(amqp_uri, exchange, "json", message) with patch('nameko.standalone.rpc._logger', autospec=True) as logger: responder.send_response(None, None) assert proxy.spam(ham='eggs') == 'eggs' assert logger.debug.call_count == 1
def test_unexpected_correlation_id(container_factory, rabbit_config): container = container_factory(FooService, rabbit_config) container.start() with ServiceRpcProxy("foobar", rabbit_config) as proxy: message = Message(channel=None, properties={ 'reply_to': proxy.reply_listener.routing_key, 'correlation_id': 'invalid', 'content_type': 'application/json' }) amqp_uri = container.config['AMQP_URI'] exchange = get_rpc_exchange(container.config) responder = Responder(amqp_uri, exchange, "json", message) with patch('nameko.standalone.rpc._logger', autospec=True) as logger: responder.send_response(None, None) assert proxy.spam(ham='eggs') == 'eggs' assert logger.debug.call_count == 1
def rpc_consumer_handle_result(self, message, result, exc_info): from sv_base.extensions.service.rpc import RpcResult if isinstance(result, RpcResult): rpc_result = result amqp_uri = self.container.config[AMQP_URI_CONFIG_KEY] serializer = self.container.config.get(SERIALIZER_CONFIG_KEY, DEFAULT_SERIALIZER) exchange = get_rpc_exchange(self.container.config) ssl = self.container.config.get(AMQP_SSL_CONFIG_KEY) responder = Responder(amqp_uri, exchange, serializer, message, ssl=ssl) result, exc_info = responder.send_response(rpc_result.result, exc_info) self.queue_consumer.ack_message(message) if rpc_result.rely_callback: rpc_result.rely_callback() return result, exc_info else: return _rpc_consumer_handle_result_default(self, message, result, exc_info)