Exemplo n.º 1
0
 def publish(self, route, message):
     if not isinstance(message, basestring):
         message = Serializer.to_json(message)
     try:
         self.channel.basic_publish(exchange=self.exchange, routing_key=route, body=message, properties=PERSIST)
     except Exception as e:
         logger = logging.getLogger(self.__class__.__name__)
         logger.error("Unable to publish the message: %s", e.message)
         logger.exception(e.message)
Exemplo n.º 2
0
 def deliver(self, message):
     """Sends the message to the next target, if any."""
     target = message.forward()
     if target is not None:
         self.logger.debug('Delivering message to %s', target)
         self.bus.publish(target, Serializer.to_json(message))