Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.5.0
-
None
-
Mac OS X 10.6.6, Eclipse Helios
Description
When splitting inside another split, the custom aggregationStrategy is not used. For example in the route:
<route id="DoubleSplitRoute"> <from uri="direct:in" /> <setBody> <constant> <a> <b> <c>Hello</c> <c>World</c> </b> <b> <c>Hello</c> <c>again</c> </b> </a> </constant> </setBody> <split> <xpath>a/b</xpath> <split strategyRef="concatWithSpaceStrategy"> <xpath>b/c/text()</xpath> <setBody><simple>${bodyAs(java.lang.String)}</simple></setBody> <log message="Got a part: ${body}"/> </split> <log message="Got a result: ${body}"/> </split> </route>
(where the concatWithSpaceStrategy does nothing more than to concat the bodies with a space inbetween.)
The expected results would be:
Got a result: Hello World
and
Got a result: Hello again
But that is not what happens. The actual results are two times the same:
Got a result: <a> <b> <c>Hello</c> <c>World</c> </b> <b> <c>Hello</c> <c>again</c> </b> </a>
The reason is, that the strategy is not used. In the class org.apache.camel.processor.MulticastProcessor, in the method protected AggregationStrategy getAggregationStrategy(Exchange exchange), the first step is to find an aggregationStrategy in the Exchange. This is set to UseOriginalAggregationStrategy, and because it is not null, this aggregation strategy will be used, not the one declared for the splitter.
—
A workaround would be to remove the AggregationStrategy of the Exchange, before it is aggregated, by using a processor with the following process method:
public void process(Exchange exchange) throws Exception { if (exchange != null) { exchange.removeProperty(Exchange.AGGREGATION_STRATEGY); } }
After integrating this in my route, I got the desired results.