/**
  * @param object                        $messageInstance
  * @param IncomingLogicalMessageFactory $helperFactory
  */
 public function updateInstance($messageInstance, IncomingLogicalMessageFactory $helperFactory)
 {
     if (!is_object($messageInstance)) {
         throw new InvalidArgumentException('Message instance must be an object.');
     }
     if ($messageInstance === $this->messageInstance) {
         return;
     }
     $helperLogicalMessage = $helperFactory->createFromObject($messageInstance);
     $this->messageInstance = $messageInstance;
     $this->messageClass = $helperLogicalMessage->getMessageClass();
     $this->messageInterfaces = $helperLogicalMessage->getMessageInterfaces();
 }
 /**
  * @param IncomingPhysicalMessage $physicalMessage
  *
  * @return IncomingLogicalMessage|null
  */
 private function extractMessage(IncomingPhysicalMessage $physicalMessage)
 {
     $body = $physicalMessage->getBody();
     if ($body === null || $body === '') {
         return null;
     }
     if (!isset($physicalMessage->getHeaders()[HeaderTypeEnum::ENCLOSED_CLASS])) {
         return null;
     }
     $messageClass = $physicalMessage->getHeaders()[HeaderTypeEnum::ENCLOSED_CLASS];
     $serializer = $this->deserializerResolver->resolve($physicalMessage->getHeaders());
     $instanceMessage = $serializer->deserialize($body, $messageClass);
     return $this->logicalMessageFactory->createFromObject($instanceMessage);
 }