/** * Processes the given exchange * This method is the entry point for splitting the given exchange into * its parts via the split rule. Subclasses can change the created sub * exchanges by overriding {@link #finalizeSubExchange(Exchange, Exchange, SplitIndex)} * and the aggregate result by overriding {@link #finalizeAggregate(Exchange, Exchange)}. * * @param origExchange exchange that should be split by this processor */ @Override protected void processNext(Exchange origExchange) throws Exception { notNull(origExchange, "origExchange"); Iterable splitResult = evaluateSplitRule(origExchange); Exchange aggregate = processAllResults(origExchange, splitResult); finalizeAggregate(origExchange, aggregate); }
@Override protected void finalizeAggregate(Exchange origExchange, Exchange aggregate) { ManagedMessage origMessage = new PlatformMessage(origExchange); SplitHistory origHistory = origMessage.getSplitHistory(); // The aggregate needs to be copied to ensure that we can change it // without affecting the input into the destination processor of the // splitter. if (aggregate != null){ Exchange copiedAggregate = aggregate.copy(); ManagedMessage message = new PlatformMessage(copiedAggregate); SplitHistory aggregateHistory = message.getSplitHistory(); if (!aggregateHistory.equals(origHistory)) { message.setSplitHistory(origHistory); } super.finalizeAggregate(origExchange, copiedAggregate); } else { super.finalizeAggregate(origExchange, aggregate); } }