/**
  * @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 OutgoingSendContext $context
  * @param callable            $next
  */
 public function invoke($context, callable $next)
 {
     $addressTags = $this->unicastRouter->route($context->getSendOptions(), $context->getMessageClass());
     if (empty($addressTags)) {
         throw new RoutingException("The message destination could not be determined. You may have misconfigured the destination for this kind of message ({$context->getMessageClass()}) when you registered the message to endpoint mappings.");
     }
     $context->setHeader(HeaderTypeEnum::MESSAGE_INTENT, MessageIntentEnum::SEND);
     $logicalMessageContext = $this->contextFactory->createLogicalMessageContextFromSendContext($addressTags, $context);
     $next($logicalMessageContext);
 }
 /**
  * @param OutgoingReplyContext $context
  * @param callable             $next
  */
 public function invoke($context, callable $next)
 {
     $replyToAddress = $context->getReplyOptions()->getExplicitDestination();
     if (!$replyToAddress) {
         $replyToAddress = $this->getReplyToAddressFromIncomingMessage($context->getIncomingPhysicalMessage());
     }
     $context->setHeader(HeaderTypeEnum::MESSAGE_INTENT, MessageIntentEnum::REPLY);
     $logicalMessageContext = $this->contextFactory->createLogicalMessageContextFromReplyContext($replyToAddress, $context);
     $next($logicalMessageContext);
 }
Example #4
0
 /**
  * @param PendingTransportOperations     $pendingTransportOperations
  * @param IncomingPhysicalMessageContext $physicalMessageContext
  */
 private function dispatchPendingOperations(PendingTransportOperations $pendingTransportOperations, IncomingPhysicalMessageContext $physicalMessageContext)
 {
     if ($pendingTransportOperations->hasOperations()) {
         $dispatchContext = $this->outgoingContextFactory->createDispatchContext($pendingTransportOperations->getOperations(), $physicalMessageContext);
         $this->dispatchPipeline->invoke($dispatchContext);
     }
 }
 /**
  * @param TransportReceiveContext $context
  * @param callable                $next
  */
 public function invoke($context, callable $next)
 {
     try {
         $next();
     } catch (CriticalErrorException $e) {
         // all hope is gone
         throw $e;
     } catch (\Exception $e) {
         $incomingMessage = $context->getMessage();
         $incomingMessage->revertToOriginalBodyIfNeeded();
         $exceptionHeaders = $this->exceptionConverter->convert($e, $this->localAddress);
         $newHeaders = array_merge($incomingMessage->getHeaders(), $exceptionHeaders);
         $outgoingMessage = new OutgoingPhysicalMessage($incomingMessage->getMessageId(), $newHeaders, $incomingMessage->getBody());
         $dispatchContext = $this->contextFactory->createDispatchContext([new TransportOperation($outgoingMessage, new UnicastAddressTag($this->errorQueueAddress))], $context);
         $this->dispatchPipeline->invoke($dispatchContext);
     }
 }
 /**
  * @param OutgoingPublishContext $context
  * @param callable               $next
  */
 public function invoke($context, callable $next)
 {
     $context->setHeader(HeaderTypeEnum::MESSAGE_INTENT, MessageIntentEnum::PUBLISH);
     $logicalMesageContext = $this->contextFactory->createLogicalMessageContextFromPublishContext($context);
     $next($logicalMesageContext);
 }