/** * @param OutgoingLogicalMessageContext $context * @param callable $next */ public function invoke($context, callable $next) { $correlationId = null; if ($context->getIncomingPhysicalMessage()) { $incomingHeaders = $context->getIncomingPhysicalMessage()->getHeaders(); if (isset($incomingHeaders[HeaderTypeEnum::CORRELATION_ID])) { $correlationId = $incomingHeaders[HeaderTypeEnum::CORRELATION_ID]; } if (!$correlationId && isset($incomingHeaders[HeaderTypeEnum::MESSAGE_ID])) { $correlationId = $incomingHeaders[HeaderTypeEnum::MESSAGE_ID]; } } if (!$correlationId) { $correlationId = $context->getMessageId(); } $context->setHeader(HeaderTypeEnum::CORRELATION_ID, $correlationId); $next(); }
/** * @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(); }
/** * @param OutgoingLogicalMessageContext $context * @param callable $next */ public function invoke($context, callable $next) { $context->setHeader(HeaderTypeEnum::CONTENT_TYPE, $this->messageSerializer->getContentType()); $context->setHeader(HeaderTypeEnum::ENCLOSED_CLASS, $context->getMessage()->getMessageClass()); $body = $this->messageSerializer->serialize($context->getMessage()->getMessageInstance()); $outgoingPhysicalContext = $this->contextFactory->createPhysicalMessageContext($body, $context); $next($outgoingPhysicalContext); }
/** * @param string $body * @param OutgoingLogicalMessageContext $parentContext * * @return OutgoingPhysicalMessageContext */ public function createPhysicalMessageContext($body, OutgoingLogicalMessageContext $parentContext) { return new OutgoingPhysicalMessageContext($parentContext->getMessageId(), $parentContext->getHeaders(), new OutgoingPhysicalMessage($parentContext->getMessageId(), $parentContext->getHeaders(), $body), $parentContext->getAddressTags(), $parentContext->isImmediateDispatchEnabled(), $parentContext->getIncomingPhysicalMessage(), $parentContext->getPendingTransportOperations(), $parentContext); }
/** * @param OutgoingLogicalMessageContext $context * @param callable $next */ public function invoke($context, callable $next) { $context->setHeader(HeaderTypeEnum::REPLY_TO_ADDRESS, $this->replyToAddress); $next(); }