The current implementation assumes the existence of only one aggregation strategy which ignores the child
exchanges.

@param Exchange $mainExchange
492586
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);
        }
    }
299415
public static function Mx($preference, $exchange)
    {
        $rdata = new MX();
        $rdata->setPreference($preference);
        $rdata->setExchange($exchange);

        return $rdata;
    }
527371
protected function loadExchangeRates($targetCurrency)
    {
        if (!isset($this->exchangeRates[$targetCurrency])) {
            $currencyRates = $this->currencyRateRepository->findBy(['currencyTo' => $targetCurrency]);
            if (count($currencyRates) === 0) {
                throw new MissingCurrencyRatesException($targetCurrency);
            }
            foreach ($currencyRates as $rate) {
                $this->setExchangeRate($rate, $targetCurrency);
            }
        }
    }
1051757
public function swap(int $index1, int $index2) : void
    {
        if ($index1 !== $index2) {
            $value = $this[$index1];
            $this[$index1] = $this[$index2];
            $this[$index2] = $value;
        }
    }
400658
protected function shouldPass(Exchange $exchange)
    {
        $count = intval($this->cacheService->get($this->getCacheKeyCount()));
        $limit = $this->evaluator->evaluateWithExchange($this->limitExpression, $exchange);

        return $count < $limit;
    }
745090
private function exchangeOptions()
    {
        $builder = new NodeBuilder();

        return $builder
            ->arrayNode('exchange_options')
                ->children()
                    // base info
                    ->scalarNode('name')->isRequired()->end()
                    ->scalarNode('type')
                        ->info('Set the type of the exchange. If exchange already exist - you can skip it. Otherwise behavior is unpredictable')
                    ->end()

                    // flags
                    ->booleanNode('passive')->defaultFalse()->end()
                    ->booleanNode('durable')->defaultTrue()->end()
                    ->booleanNode('auto_delete')->defaultFalse()->end()

                    // args
                    ->arrayNode('arguments')
                        ->prototype('scalar')->end()
                        ->defaultValue(array())
                        ->normalizeKeys(false)
                    ->end()

                    // binding
                    ->arrayNode('routing_keys')
                        ->prototype('scalar')->end()
                        ->defaultValue(array())
                    ->end()

                    // default message attributes
                    ->arrayNode('publish_attributes')
                        ->prototype('scalar')->end()
                        ->defaultValue(array())
                    ->end()
                ->end();
            //last end is missed here intentionally because arrayNode doesn't have an actual parent
    }
151037
@Override
    public void handleRequest(final HttpServerExchange exchange) throws Exception {
        if(exchange.isInIoThread()) {
            exchange.dispatch(this);
            return;
        }
        SecurityContext context = exchange.getSecurityContext();
        if (context.authenticate()) {
            if(!exchange.isComplete()) {
               next.handleRequest(exchange);
            }
        } else {
            exchange.endExchange();
        }
    }
429693
private void setExchangeRateChain(List<ExchangeRate> chain) {
        this.chain.clear();
        if (chain==null || chain.isEmpty()) {
            this.chain.add(this);
        } else {
            for (ExchangeRate rate : chain) {
                if (rate==null) {
                    throw new IllegalArgumentException("Rate Chain element can not be null.");
                }
            }
            this.chain.addAll(chain);
        }
    }
1091331
private function _addExclusionStrategy(ExclusionStrategyInterface $strategy): void
    {
        if (null === $this->exclusionStrategy) {
            $this->exclusionStrategy = $strategy;

            return;
        }

        if ($this->exclusionStrategy instanceof DisjunctExclusionStrategy) {
            $this->exclusionStrategy->addStrategy($strategy);

            return;
        }

        $this->exclusionStrategy = new DisjunctExclusionStrategy([
            $this->exclusionStrategy,
            $strategy,
        ]);
    }
823554
private void fireOnDeleteExchange(ChannelEvent e) {
        List<EventListener> listeners = changes.getListenerList(AMQP);
        for (EventListener listener : listeners) {
            ChannelListener amqpListener = (ChannelListener)listener;
            amqpListener.onDeleteExchange(e);
        }
    }
1099520
public Reflecter<T> setExchangeFuncs(Map<String, Function<?, ?>> exchangeFuncMap) {
		exchangeFuncs.putAll(checkNotNull(exchangeFuncMap));
		return this;
	}
1312532
private void processMessages(int idx) {
        LOG.finest("Processing thread " + idx + " starting...");
        try {
            HTTPExchange exch;
            do {
                exch = nextExchange(idx);
                if (exch == null) {
                    break;
                }

                // Test hook to manipulate what the client sees:
                ExchangeInterceptor interceptor = exchInterceptor.get();
                if (interceptor != null) {
                    HTTPExchange newExch = interceptor.interceptExchange(exch);
                    if (newExch == null) {
                        LOG.log(Level.FINE, "Discarding exchange on request "
                                + "of test hook: RID="
                                + exch.getRequest().getAttribute(
                                    Attributes.RID));
                        lock.lock();
                        try {
                            exchanges.remove(exch);
                        } finally {
                            lock.unlock();
                        }
                        continue;
                    }
                    exch = newExch;
                }

                processExchange(idx, exch);
            } while (true);
        } finally {
            LOG.log(Level.FINEST, "Processing thread exiting: " + idx);
        }

    }
773741
protected function _onChangeResetCounts($sOxid, $sVendorId = null, $sManufacturerId = null)
    {
        $myUtilsCount = \OxidEsales\Eshop\Core\Registry::getUtilsCount();

        if ($sVendorId) {
            $myUtilsCount->resetVendorArticleCount($sVendorId);
        }

        if ($sManufacturerId) {
            $myUtilsCount->resetManufacturerArticleCount($sManufacturerId);
        }

        $aCategoryIds = $this->getCategoryIds();
        //also reseting category counts
        foreach ($aCategoryIds as $sCatId) {
            $myUtilsCount->resetCatArticleCount($sCatId);
        }
    }
1221666
protected function dispatchEvent(Exchange $exchange, $eventName)
    {
        $event = new HandlerEvent($eventName);
        $event->setTimestampToCurrent();
        $event->setExchange($exchange);
        $this->eventDispatcher->dispatch($eventName, $event);
    }
420012
public boolean removeExecutedTradeCallback(final BitfinexExecutedTradeSymbol tradeSymbol,
			final BiConsumer<BitfinexExecutedTradeSymbol, BitfinexExecutedTrade> callback) throws BitfinexClientException {

		return tradesCallbacks.removeCallback(tradeSymbol, callback);
	}
805978
public function deleteExchange($name, $flags = AMQP_NOPARAM)
    {
        if (!isset($this->_exchanges[$name])) {
            throw new InvalidKeyException(['delete `:exchange` exchange failed: it is NOT exists', 'exchange' => $name]);
        }

        try {
            $this->_exchanges[$name]->delete($flags);
        } catch (\Exception $e) {
            throw new AmqpException(['delete `:exchange` exchange failed: :error', 'exchange' => $name, 'error' => $e->getMessage()]);
        }

        unset($this->_exchanges[$name]);

        return $this;
    }
342872
protected function getHistoricalExchangeRate(HistoricalExchangeRateQuery $exchangeQuery): ExchangeRateContract
    {
        $currencyPair = $exchangeQuery->getCurrencyPair();
        $baseCurrency = $currencyPair->getBaseCurrency();
        $date = $exchangeQuery->getDate();
        $formattedDate = $date->format('Ymd');

        $content = $this->request(self::URL.'?'.http_build_query(['date' => $formattedDate]));
        $element = StringUtil::xmlToElement($content);

        $elements = $element->xpath('./currency[cc="'.$baseCurrency.'"]');

        if (empty($elements)) {
            if ($element->xpath('./error')) {
                throw new UnsupportedDateException($date, $this);
            }

            throw new UnsupportedCurrencyPairException($currencyPair, $this);
        }

        $item = $elements[0];

        $rate = (float) str_replace(',', '.', (string) $item->rate);

        return $this->createRate($currencyPair, $rate, $date);
    }