def on_response(self, ch, method, properties, body): try: message_type = self._topic_names_to_types[method.exchange + ':' + method.routing_key] message = ProtoUtil.string_to_message( message_type=message_type, string=base64.b64decode(body)) return self.parse_message(exchange_name=method.exchange, topic_name=method.routing_key, message=message) except Exception as err: self._logger.error("Getting response with error " + str(err) + '.')
def _process_message(self, ch, method, props, body): try: generic_request = ProtoUtil.string_to_message( message_type=GenericRPCRequest, string=base64.b64decode(body) ) self._logger.info("Getting request with uuid [" + generic_request.uuid + '] in consumer [' + self.get_consumer_name() + '].') response = self._queue.send_request(request=generic_request) response_str = ProtoUtil.message_to_string(proto_message=response) ch.basic_publish(exchange='', routing_key=props.reply_to, properties=pika.BasicProperties(correlation_id=props.correlation_id), body=base64.b64encode(response_str)) ch.basic_ack(delivery_tag=method.delivery_tag) except Exception as err: self._logger.error("Consumer [" + self.get_consumer_name() + "] processing message with error: " + str(err) + '.')
def on_response(self, ch, method, props, body): if self._corr_id == props.correlation_id: self._response = ProtoUtil.string_to_message( message_type=GenericRPCResponse, string=base64.b64decode(body))