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

Claus Ibsen commented on CAMEL-8285:
------------------------------------

What kind of transactions are you talking about? single resources or XA. The 
latter with XA ought to let the TX manage orchestrate it all about commit / 
rollback, and just by using the XADataSource it should work - I assume.

For single resource if the idea is to defer the commit to the end of the route, 
then yeah I guess maybe the connection should be reused or not returned to the 
pool. So maybe the component detects that the exchange is transacted, eg 
exchange.isTransacted() and if so it grabs the connection and keep it around, 
and only return it to the pool when the exchange UoW is done.

> JdbcProducer should rather use spring's DataSourceUtils.getConnection(ds) 
> when in transacted() block
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-8285
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8285
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jdbc
>    Affects Versions: 2.14.1
>            Reporter: Grzegorz Grzybek
>            Priority: Minor
>
> JdbcProducer gets {{java.sql.Connection}} by direct call to 
> {{javax.sql.DataSource#getConnection()}}. But depending on dataSource used, 
> the acquired connection may not be the correct JDBC connection (and 
> XAResource in case of XA transactions) which is currently associated with 
> {{org.springframework.transaction.PlatformTransactionManager}} used by 
> {{org.springframework.transaction.support.TransactionTemplate}} which is used 
> by Camel's {{<transacted>}} 
> ({{org.apache.camel.spring.spi.TransactionErrorHandler}}).
> JdbcProducer might use:
> * org.springframework.jdbc.datasource.DataSourceUtils#getConnection()
> * org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection()
> just like Spring's {{JdbcTemplate}} does it (and camel-sql component uses).



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

Reply via email to