Core/Processors/Routing/Multicast.php
protected function doProcess(Exchange $mainExchange, SerializableArray $processingContext)
    {
        foreach ($this->itineraries as $itinerary) {
            $exchange = new Exchange();

            // Set headers
            if (!empty($mainExchange->getHeaders())) {
                $exchange->setHeaders($mainExchange->getHeaders());
            }

            $exchange->setHeader(Exchange::HEADER_HANDLER, $mainExchange->getHeader(Exchange::HEADER_HANDLER));
            $exchange->setHeader(Exchange::HEADER_PARENT_EXCHANGE, $mainExchange->getId());
            $exchange->setHeader(Exchange::HEADER_FROM, $mainExchange->getHeader(Exchange::HEADER_FROM));

            // Set Itinerary
            $exchange->getItinerary()->prepend($itinerary);
            $exchange->getItinerary()->setName('Multicast from "'.$mainExchange->getItinerary()->getName().'"');

            // Set Message
            $msgCopy = unserialize(serialize($mainExchange->getIn()));
            $exchange->setIn($msgCopy);

            $event = new NewExchangeEvent($exchange);
            $event->setTimestampToCurrent();
            $this->eventDispatcher->dispatch(NewExchangeEvent::TYPE_NEW_EXCHANGE_EVENT, $event);
        }
    }
protected function doProcess(Exchange $mainExchange, SerializableArray $processingContext)
    {
        foreach ($this->itineraries as $itinerary) {
            $exchange = new Exchange();

            // Set headers
            if (!empty($mainExchange->getHeaders())) {
                $exchange->setHeaders($mainExchange->getHeaders());
            }

            $exchange->setHeader(Exchange::HEADER_HANDLER, $mainExchange->getHeader(Exchange::HEADER_HANDLER));
            $exchange->setHeader(Exchange::HEADER_PARENT_EXCHANGE, $mainExchange->getId());
            $exchange->setHeader(Exchange::HEADER_FROM, $mainExchange->getHeader(Exchange::HEADER_FROM));

            // Set Itinerary
            $exchange->getItinerary()->prepend($itinerary);
            $exchange->getItinerary()->setName('Multicast from "'.$mainExchange->getItinerary()->getName().'"');

            // Set Message
            $msgCopy = unserialize(serialize($mainExchange->getIn()));
            $exchange->setIn($msgCopy);

            $event = new NewExchangeEvent($exchange);
            $event->setTimestampToCurrent();
            $this->eventDispatcher->dispatch(NewExchangeEvent::TYPE_NEW_EXCHANGE_EVENT, $event);
        }
    }
protected function doProcess ( Exchange $ mainExchange , SerializableArray $ processingContext ) { foreach ( $ this -> itineraries as $ itinerary ) { $ exchange = new Exchange ( ) ; // Set headers if ( ! empty ( $ mainExchange -> getHeaders ( ) ) ) { $ exchange -> setHeaders ( $ mainExchange -> getHeaders ( ) ) ; } $ exchange -> setHeader ( Exchange :: HEADER_HANDLER , $ mainExchange -> getHeader ( Exchange :: HEADER_HANDLER ) ) ; $ exchange -> setHeader ( Exchange :: HEADER_PARENT_EXCHANGE , $ mainExchange -> getId ( ) ) ; $ exchange -> setHeader ( Exchange :: HEADER_FROM , $ mainExchange -> getHeader ( Exchange :: HEADER_FROM ) ) ; // Set Itinerary $ exchange -> getItinerary ( ) -> prepend ( $ itinerary ) ; $ exchange -> getItinerary ( ) -> setName ( 'Multicast from "' . $ mainExchange -> getItinerary ( ) -> getName ( ) . '"' ) ; // Set Message $ msgCopy = unserialize ( serialize ( $ mainExchange -> getIn ( ) ) ) ; $ exchange -> setIn ( $ msgCopy ) ; $ event = new NewExchangeEvent ( $ exchange ) ; $ event -> setTimestampToCurrent ( ) ; $ this -> eventDispatcher -> dispatch ( NewExchangeEvent :: TYPE_NEW_EXCHANGE_EVENT , $ event ) ; } }
The current implementation assumes the existence of only one aggregation strategy which ignores the child
exchanges.

@param Exchange $mainExchange
The current implementation assumes the existence of only one aggregation strategy which ignores the child exchanges .