Federico Mariani created CAMEL-27021:
----------------------------------------

             Summary: camel-core - transacted uses a new local 
JdbcTransactionManager when the registry has two or more transaction managers
                 Key: CAMEL-27021
                 URL: https://issues.apache.org/jira/browse/CAMEL-27021
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Federico Mariani


Since CAMEL-26851, {{transacted()}} without a policy makes a local 
{{JdbcTransactionManager}} when 
{{findSingleByType(PlatformTransactionManager.class)}} returns null. That 
method returns null when there is no transaction manager, and also when there 
are two or more.

With two or more transaction managers and one {{DataSource}}, the route starts. 
Camel binds a new {{JdbcTransactionManager}} for the {{DataSource}} as 
{{transactionManager}} and the route uses it: none of the transaction managers 
of the application begins a transaction. Only an INFO line is logged, and it 
does not mention the other transaction managers.

{code:java}
registry.bind("ds", dataSource);
registry.bind("txA", new DataSourceTransactionManager(dataSource));
registry.bind("txB", new DataSourceTransactionManager(dataSource));

from("direct:start").transacted()
    .to("sql:insert into customer values('cust1','cmueller')?dataSource=#ds");
// starts, and runs in a transaction of a new JdbcTransactionManager, not of 
txA or txB
{code}

With two {{DataSource}} beans, the route fails with 
{{NoSuchBeanTypeException}}: "No bean could be found in the registry for: 
org.springframework.transaction.PlatformTransactionManager", though there are 
two.

Expected: the local transaction manager is made only when the registry has no 
transaction manager, as the transactional client page says. With two or more, 
the route fails to start, as in 4.23.0, and the message says how many were 
found.

_Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to