示例#1
0
文件: Channel.php 项目: znk3r/mqlib
 /**
  * @param Outgoing         $message
  * @param AbstractExchange $exchange
  *
  * @return $this
  */
 public function sendMessage(Outgoing $message, AbstractExchange $exchange)
 {
     if ($message->hasReturnListener()) {
         $this->channel->set_return_listener($message->getReturnListener());
     }
     $this->channel->basic_publish($message->getAMQPMessage(), $exchange->getName(), $message->getRoutingKey(), $message->isMandatory(), $message->isImmediate());
     return $this;
 }
示例#2
0
 /**
  * @inheritdoc
  */
 public function setReturnCallback(callable $returnCallback = null)
 {
     if (!$returnCallback) {
         return;
     }
     $innerCallback = function ($replyCode, $replyText, $exchange, $routingKey, $message) use($returnCallback) {
         $envelope = new Envelope($message);
         return $returnCallback($replyCode, $replyText, $exchange, $routingKey, $envelope, $envelope->getBody());
     };
     $this->channel->set_return_listener($innerCallback);
 }