Question

I have the below configuration for my jdbc-inbound-adapter:

    <si-jdbc:inbound-channel-adapter id="jdbcInboundAdapter"
    channel="queueChannel" data-source="myDataSource"
    auto-startup="true"
    query="SELECT * FROM STAGE_TABLE WHERE STATUS='WAITING'  FOR UPDATE SKIP LOCKED"
    update="UPDATE STAGE_TABLE SET STATUS='IN_PROGRESS' WHERE ID IN (:Id)"
    max-rows-per-poll="100" row-mapper="rowMapper"
    update-per-row="true">

    <si:poller fixed-rate="5000">
        <si:advice-chain> 
            <ref bean="txAdvice"/> 
            <ref bean="inboundAdapterConfiguration"/> 
        </si:advice-chain>
    </si:poller>
</si-jdbc:inbound-channel-adapter>
    <tx:advice id="txAdvice">
        <tx:attributes>
            <tx:method name="get*" read-only="false"/>
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>

My question is does the both select and update statements would be executed in the same transaction.

In the spring-integration documentation it does not specify clearly about the transaction when advice-chain is used. (I am using spring-integration-jdbc-2.2.0.RC2.jar) Please see section 18.1.1 Poller Transaction Support: http://docs.spring.io/spring-integration/docs/2.0.0.RC1/reference/html/transactions.html

Was it helpful?

Solution

You are using a very old version (and only a release candidate at that, not a GA release. The current version is 3.0.2.RELEASE the latest 2.2.x is 2.2.6.RELEASE. Please upgrade to one of those.

http://projects.spring.io/spring-integration/

Yes, it's all done in the same transaction.

Are you referring to the old documentation too? The current documentation says

"A very important feature of the poller for JDBC usage is the option to wrap the poll operation in a transaction,..".

The transaction is started, the message source is invoked (to get the results) and the downstream flow all occurs in the transaction (unless you hand off to another thread, in which case the transaction will commit at that time).

In fact, the update is done right after the select (and before the message is sent), but the commit doesn't occur until the downstream flow is complete.

Your channel is called queueChannel; if it really is a queue channel, that means that the transaction will commit as soon as the message is stored in the queue.

If you feel documentation improvements are required, please open a JIRA Issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top