/** * @param Delivery $message * * @return Response * * @throws ReplyException */ protected function createResponse(Delivery $message) { $headers = $message->getHeaders(); if (!empty($headers['x-error'])) { throw new ReplyException($headers['x-error'], isset($headers['x-error-code']) ? $headers['x-error-code'] : 0); } $value = $this->getEncoder()->decode(new Encoded($message->getProperty('content-type', null), $message->getBody())); return new Response($value, $headers); }
/** * Create and publish reply message for given request message. * * @param Delivery $request * @param string $body */ private function reply(Delivery $request, $body) { $reply = new Message($body, ['correlation-id' => $request->getProperty('correlation-id')]); $this->channel->publish($reply, '', $request->getProperty('reply-to')); }