You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gianfranco Luceri <gl...@gmail.com> on 2017/07/31 11:49:35 UTC
Camel 2.19.1 and Aggregate2 EIP
Hello everybody. I'm experiencing odd behavior with aggregate2 EIP resulting in correct aggregation but wrong CamelAggregatedCorrelationKey value.
In particular, the following dsl return different results depending on the way the value of the header "streamStr" is computed.
If I use the first js funciton (the commented one), everything works fine. If I use the second one, the CamelAggregatedCorrelationKey has wrong values (st1 is missing)
Anybody else experiencing this odd behavior?
I did some debug in the source code and I suspect the odd behavior depends on the way the AggregateProcessor updates the AGGREGATED_CORRELATION_KEY property value in the method "onCompletion" at lines 664-665. In fact, the method is called while looping through every batchKey from the batchConsumerCorrelationKeys but the "original" Exchange passed as parameter is never updated since its first retrieval. So, if it is belonging to the last batchKey (it seems to be so in most cases) everithing works fine; otherwise the odd behavior (bug?)
Any help is appreciated.
What follows is a camel DSL I used to reproduce the issue.
Thank you
<!-- TEST DSL -->
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
">
<!--
mkdir /tmp/src/
cd /tmp/src
touch st1-1-1.txt
touch st1-1-2.txt
touch st1-1-3.txt
touch st2-1-1.txt
touch st2-1-2.txt
touch st2-1-3.txt
touch st3-1-1.txt
touch st3-1-2.txt
touch st3-1-3.txt
The correlated keys should be: st1, st2, st3
The correlated keys will be: st3, st2, st3
The st1 key got lost!
-->
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="test2Start" autoStartup="true">
<from uri="file:///tmp/src?delay=5000&noop=false"/>
<setHeader headerName="streamIdx">
<simple>${headers.CamelBatchIndex}</simple>
</setHeader>
<setHeader headerName="streamStr">
<!--language language="javaScript">'st' + (Math.floor(request.headers.get('streamIdx') / 3)+1)</language-->
<language language="javaScript">''+request.headers.get('CamelFileName').split('-')[0]</language>
</setHeader>
<log message="File/stream: ${headers.CamelFileName}/${headers.streamStr}"/>
<to uri="direct:test2Aggregate"/>
</route>
<route id="test2Aggregate">
<from uri="direct:test2Aggregate"/>
<aggregate groupExchanges="true" completionFromBatchConsumer="true" eagerCheckCompletion="true">
<camel:correlationExpression>
<language language="javaScript">request.headers.get('streamStr')</language>
</camel:correlationExpression>
<to uri="direct:test2complete"/>
</aggregate>
</route>
<route id="test2complete">
<from uri="direct:test2complete"/>
<log message="CamelAggregatedCorrelationKey=${property.CamelAggregatedCorrelationKey}"/>
</route>
</camelContext>
</blueprint>