/** * @param Envelope $envelope * @return array */ protected function extractMessageInformation(Envelope $envelope) : array { return ['body' => $envelope->getBody(), 'routing_key' => $envelope->getRoutingKey(), 'type' => $envelope->getType()]; }
/** * @param Envelope $envelope * @return Request * @throws Exception\InvalidJsonRpcVersion * @throws Exception\JsonParseError */ protected function requestFromEnvelope(Envelope $envelope) : Request { if ($envelope->getHeader('jsonrpc') !== JsonRpcRequest::JSONRPC_VERSION) { throw new Exception\InvalidJsonRpcVersion(); } if ($envelope->getContentEncoding() !== 'UTF-8' || $envelope->getContentType() !== 'application/json') { throw new Exception\InvalidJsonRpcRequest(); } $payload = json_decode($envelope->getBody(), true); if (0 != json_last_error()) { throw new Exception\JsonParseError(); } return new JsonRpcRequest($envelope->getExchangeName(), $envelope->getType(), $payload, $envelope->getCorrelationId(), $envelope->getRoutingKey(), (int) $envelope->getExpiration(), $envelope->getTimestamp()); }