camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CAMEL-3677) When splitting inside another split, the custom aggregationStrategy is not used.
Date Thu, 17 Feb 2011 12:27:24 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-3677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995780#comment-12995780
] 

Claus Ibsen commented on CAMEL-3677:
------------------------------------

Can you try with Camel 2.6.0 - We have fixed issus with splitter in that release.

> 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

        

Mime
View raw message