private function deserializeMessage($serializedMessage, $messageClass)
    {
        $message = $this->objectSerializer->deserialize($serializedMessage, $messageClass);

        if (!($message instanceof $messageClass)) {
            throw new \LogicException(
                sprintf(
                    'Expected deserialized message to be an instance of "%s"',
                    $messageClass
                )
            );
        }

        return $message;
    }