/**
  * @param OutgoingLogicalMessageContext $context
  * @param callable                      $next
  */
 public function invoke($context, callable $next)
 {
     $mutatorIds = $this->mutatorRegistry->getOutgoingLogicalMessageMutatorIds();
     if (empty($mutatorIds)) {
         $next();
         return;
     }
     $logicalMessage = $context->getMessage();
     $messageInstance = $logicalMessage->getMessageInstance();
     $mutatorContext = new OutgoingLogicalMessageMutationContext($messageInstance, $context->getHeaders());
     foreach ($mutatorIds as $mutatorId) {
         /** @var OutgoingLogicalMessageMutatorInterface $mutator */
         $mutator = $context->getBuilder()->build($mutatorId);
         $mutator->mutateOutgoing($mutatorContext);
     }
     if ($mutatorContext->hasMessageChanged()) {
         $logicalMessage->updateInstance($mutatorContext->getMessage());
     }
     $context->replaceHeaders($mutatorContext->getHeaders());
     $next();
 }