Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A633010203 for ; Wed, 4 Mar 2015 06:52:11 +0000 (UTC) Received: (qmail 79198 invoked by uid 500); 4 Mar 2015 06:52:05 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 79161 invoked by uid 500); 4 Mar 2015 06:52:05 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 79150 invoked by uid 99); 4 Mar 2015 06:52:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Mar 2015 06:52:05 +0000 Date: Wed, 4 Mar 2015 06:52:05 +0000 (UTC) From: "Willem Jiang (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CAMEL-8424) Transaction being propagated ignoring REQUIRES_NEW when using direct component MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-8424?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Willem Jiang updated CAMEL-8424: -------------------------------- Fix Version/s: (was: 2.14.3) 2.14.2 > Transaction being propagated ignoring REQUIRES_NEW when using direct component > ------------------------------------------------------------------------------ > > Key: CAMEL-8424 > URL: https://issues.apache.org/jira/browse/CAMEL-8424 > Project: Camel > Issue Type: Bug > Components: camel-spring > Affects Versions: 2.10.7, 2.11.4, 2.13.3, 2.14.1, 2.15.0 > Reporter: Piotr Klimczak > Assignee: Claus Ibsen > Priority: Minor > Fix For: 2.13.4, 2.14.2, 2.15.0 > > > I found that when we are using exactly same propagation policy bean in different routes used together with "direct" component, then TransactionErrorHandler always propagates current transaction even if our policy is "PROPAGATION_REQUIRES_NEW". > The failing code is: > {code} > public TransactionErrorHandler(CamelContext camelContext, Processor output, CamelLogger logger, > Processor redeliveryProcessor, RedeliveryPolicy redeliveryPolicy, ExceptionPolicyStrategy exceptionPolicyStrategy, > TransactionTemplate transactionTemplate, Predicate retryWhile, ScheduledExecutorService executorService, > LoggingLevel rollbackLoggingLevel) { > super(camelContext, output, logger, redeliveryProcessor, redeliveryPolicy, null, null, false, retryWhile, executorService); > setExceptionPolicy(exceptionPolicyStrategy); > this.transactionTemplate = transactionTemplate; > this.rollbackLoggingLevel = rollbackLoggingLevel; > this.transactionKey = ObjectHelper.getIdentityHashCode(transactionTemplate); > } > @Override > public void process(Exchange exchange) throws Exception { > // we have to run this synchronously as Spring Transaction does *not* support > // using multiple threads to span a transaction > if (exchange.getUnitOfWork().isTransactedBy(transactionKey)) { > // already transacted by this transaction template > // so lets just let the error handler process it > processByErrorHandler(exchange); > } else { > // not yet wrapped in transaction so lets do that > // and then have it invoke the error handler from within that transaction > processInTransaction(exchange); > } > } > {code} > So then for each policy there is a hash code created, which then is used to verify whether current route is already transacted by this transaction policy. > This makes "PROPAGATION_REQUIRES_NEW" ignored when used with "direct" component. > So for example: > {code} > from("activemq:queue:start").routeId("route1") > .transacted("PROPAGATION_REQUIRES_NEW") > .setExchangePattern(ExchangePattern.InOnly) > .to("activemq:queue:result1") > .to("direct:route2") > .throwException(new RuntimeException("Expected!")); > from("direct:route2").routeId("route2") > .transacted("PROPAGATION_REQUIRES_NEW") > .setExchangePattern(ExchangePattern.InOnly) > .to("activemq:queue:result2"); > {code} > The above route suppose to work in 2 different transactions, as our propagation is REQUIRES_NEW for both of them. But due to hash code verification and optimisation, route2 will participate in same transaction as route1 instead of new. > This is rather buggy. > Will create pull request in minutes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)