/** * @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; }
/** * @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); }