When splitting inside another split, the custom aggregationStrategy is not used.
--------------------------------------------------------------------------------

                 Key: CAMEL-3677
                 URL: https://issues.apache.org/jira/browse/CAMEL-3677
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.5.0
         Environment: Mac OS X 10.6.6, Eclipse Helios
            Reporter: Oliver Jelinski
            Priority: Minor


When splitting inside another split, the custom aggregationStrategy is not 
used. For example in the route:

{code:xml}
            <route id="DoubleSplitRoute">
                <from uri="direct:in" />
                <setBody>
                        <constant>
&lt;a&gt;
        &lt;b&gt;
                &lt;c&gt;Hello&lt;/c&gt;
                &lt;c&gt;World&lt;/c&gt;
        &lt;/b&gt;
        &lt;b&gt;
                &lt;c&gt;Hello&lt;/c&gt;
                &lt;c&gt;again&lt;/c&gt;
        &lt;/b&gt;
&lt;/a&gt;
                        </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>
{code}

(where the {{concatWithSpaceStrategy}} does nothing more than to concat the 
bodies with a space inbetween.)

The expected results would be:

{code}
Got a result: Hello World
{code}

and 

{code}
Got a result: Hello again
{code}

But that is not what happens. The actual results are two times the same:

{code}
Got a result: 
<a>
        <b>
                <c>Hello</c>
                <c>World</c>
        </b>
        <b>
                <c>Hello</c>
                <c>again</c>
        </b>
</a>
{code}

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:

{code:java}
        public void process(Exchange exchange) throws Exception {
                if (exchange != null) {
                        exchange.removeProperty(Exchange.AGGREGATION_STRATEGY);
                }
        }
{code}

After integrating this in my route, I got the desired results.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to