[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

split(), shareUnitOfWork & transacted()

I have a question on propagating a transaction with split() and shareUnitOfWork(). I have a route defined below in Camel 2.20.2.  I read transactions from Datasource1, I split the result set, send each row to a recipient list which uses Datasource2, and then mark the row as processed.  I perform a select for update when reading the transactions from Datasource1.


                // Select all transactions to process
                                .setHeader("transactionId", simple("${body.transactionId}"))

                                // Datasource2 recipients

                                // Update dateProcessed.

I want the "select for update" and the "update" to take place in the same transaction.  Through the use of the transacted() and shareUnitOfWork() calls, I would expect that select and update would be using the same connection to Oracle.  However, it appears that there are two connections being used - 1 for the select for update and 1 for the update.  Upon running the update inside of the split(), the route waits for the release from the select for update.

Do I have the route and Spring context config correct?

The Spring context file has the following configuration for the datasources.

<jee:jndi-lookup expected-type="javax.sql.DataSource" id="Datasource1" jndi-name="jdbc/Datasource1"/>
<jee:jndi-lookup expected-type="javax.sql.DataSource" id="Datasource2" jndi-name="jdbc/Datasource2"/>

<bean id="datasource1TxManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                <property name="dataSource" ref="Datasource1" />

<bean id="datasource2TxManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                <property name="dataSource" ref="Datasource2" />

<bean id="TRANS_REQUIRESNEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
                  <property name="transactionManager">
                  <bean id="txMgrRouting" class="">
                                                <ref bean="datasource1TxManager"/>
                                                <ref bean="datasource2TxManager"/>
                <property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>


( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03515.html on line 121
Call Stack
10.0006368664{main}( ).../msg03515.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03515.html on line 121
Call Stack
10.0006368664{main}( ).../msg03515.html:0