Marc Carter created CAMEL-8074:
----------------------------------

             Summary: Aggregator doesn't honour policies for messages completed 
on a different thread
                 Key: CAMEL-8074
                 URL: https://issues.apache.org/jira/browse/CAMEL-8074
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.14.0
            Reporter: Marc Carter


The following Java EIP looks textbook but the post-aggregation route is _not_ 
transacted as it runs on a different thread. The (transaction) policy meant to 
wrap the route doesn't get re-applied to the output.

{code:java}
from("direct:in")
 .transacted("requiresTransaction")
 .aggregate(simple("${header.symbol}"), new UseLatestAggregationStrategy())
    .completionInterval(1000)
  .bean(persistInDb)
  .to("jms:output");
{code}

Since one cannot re-specify the transacted policy on the same route, the only 
workaround is to break it in two.
{code:java}
from("direct:in")
 .transacted("requiresTransaction")
 .aggregate(simple("${header.symbol}"), new UseLatestAggregationStrategy())
    .completionInterval(1000)
  .to("direct:x");
from("direct:x")
  .transacted("requiresTransaction")
  .bean(persistInDb)
  .to("jms:output");
{code}

Proposal is to ensure the route's transaction Policies is re-applied inside of 
the AggregateProcessor#onSubmitCompletion runnable if (and only if!) the 
current thread is not the one which started the route (which may be better 
inferred through {{exchange.getUnitOfWork}} - just a guess). 



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

Reply via email to