Example #1
0
 /**
  * @param MessageInterface $message
  * @return AMQPMessage
  */
 public static function toAMQPMessage(MessageInterface $message)
 {
     $deliveryMode = $message->getDeliveryMode();
     $properties = $message->getProperties();
     $properties['application_headers'] = new AMQPTable($message->getHeaders());
     $properties['delivery_mode'] = $deliveryMode ?: MessageInterface::DELIVERY_MODE_PERSISTENT;
     // default: durable
     return new AMQPMessage($message->getPayload(), $properties);
 }
Example #2
0
 /**
  * @inheritdoc
  * @todo Add more message properties
  */
 public function publish($exchangeName, MessageInterface $message, $routingKey = null)
 {
     try {
         $props = $message->getProperties();
         $props['delivery_mode'] = $message->getDeliveryMode();
         return $this->getExchange($exchangeName)->publish($message->getPayload(), $routingKey, AMQP_NOPARAM, $props);
     } catch (\Exception $e) {
         throw Helper\Exception::convert($e);
     }
 }