/** * @param RpcResponseMessage $response * * @throws MessageException */ protected function onResponse(RpcResponseMessage $response) { $this->logger->notice('Message received!', ['body' => $response->getBody(), 'properties' => $response->getProperties()]); try { $this->rpcResponse = $response; if ($this->correlarionId != $this->rpcResponse->getCorrelationId()) { throw MessageException::wrongCorrelationId($this->rpcResponse->getCorrelationId(), $this->correlarionId); } // Send ack $this->connector->basicAck($response); } catch (\Exception $e) { // Create an error response and reject message $responsePayload = RpcResponsePayload::create()->addError($e->getMessage()); $this->rpcResponse = MessagesBuilder::emptyRpcResponse($this->getSerializer()->getSerializedContentType(), $this->correlarionId); $this->rpcResponse->setPayload($responsePayload); $this->connector->basicReject($response, false); } }