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

ASF GitHub Bot commented on CAMEL-10272:
----------------------------------------

GitHub user aldettinger opened a pull request:

    https://github.com/apache/camel/pull/1367

    CAMEL-10272: Provide an option to stop further processing when an exc…

    …eption is thrown from an aggregation strategy while parallelProcessing is 
used.
    
    The proposed option is backward compatible, could be experimented by camel 
users on this branch, and may be elected to become the default behavior on a 
next major release.
    
    Check [CAMEL-10272](https://issues.apache.org/jira/browse/CAMEL-10272) out 
for more details.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aldettinger/camel master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/1367.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1367
    
----
commit f6ec5a03062271886d30b2ccfd6cad4c11a8afbf
Author: aldettinger <[email protected]>
Date:   2016-12-27T09:55:18Z

    CAMEL-10272: Provide an option to stop further processing when an exception 
is thrown from an aggregation strategy while parallelProcessing is used.

----


> Unexpected behaviour in aggregator if recipient list is processed in parallel
> -----------------------------------------------------------------------------
>
>                 Key: CAMEL-10272
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10272
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.16.3, 2.17.3
>         Environment: MacOS 10.11.6, JRE 1.7.0_79
>            Reporter: Peter Keller
>
> h3. Problem
> The {{oldExchange}} is {{null}} more than once in the aggregator if a 
> recipient list is processed in parallel.
> h3. Camel route
> In my Camel route, a recipient list is worked of in parallel:
> {code}
>  from("direct:start")
>     .to("direct:pre")
>     .recipientList().method(new MyRecipientListBuilder())
>         .stopOnException()
>         .aggregationStrategy(new MyAggregationStrategy())
>         .parallelProcessing()
>     .end()
>     .bean(new MyPostProcessor());
> {code}
> Snippet of {{MyAggregationStrategy}}:
> {code}
> @Override
> @SuppressWarnings("unchecked")
> public Exchange aggregate(final Exchange oldExchange, final Exchange 
> newExchange) {
>     if (oldExchange == null) {
>         // this is the case more than once which is not expected!
>     }
>     // ...
> {code}
> {{oldExchange}} is null more than once which is not expected and which 
> contradicts the contract with Camel.
> h3. Analysis
> Unfortunately, I am not able to provide a (simple) unit test for 
> comprehending the problem. Furthermore our (complex) unit tests are not 
> deterministic due to the root cause of the problem.
> During the processing, Camel invokes 
> {{ParallelAggregateTask.doAggregateInternal()}}. If aggregation is not done 
> in parallel (as it is the case in our route), this is supposed to be done 
> synchronously:
> {code}
> protected void doAggregateInternal(AggregationStrategy strategy, 
> AtomicExchange result, Exchange exchange) {
>     if (strategy != null) {
>         // prepare the exchanges for aggregation
>         Exchange oldExchange = result.get();
>         ExchangeHelper.prepareAggregation(oldExchange, exchange);
>         result.set(strategy.aggregate(oldExchange, exchange));
>     }
> } 
> {code}
> However, is it possible that we face a race condition in 
> {{doAggregateInternal}} even if this method is supposed to be invoked 
> synchronously?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to