Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Using 2 different datasources with Spring Batch

  1. #11
    Join Date
    Sep 2012
    Posts
    1

    Default

    Quote Originally Posted by lucasward View Post
    There's not too much to post, the configuration for a Step with a transaction manager is already well defined in the reference documentation:

    http://static.springframework.org/sp...n.html#d0e3409

    There's nothing stopping you from using a different transaction manager in your Dao from the one you wired in your step. However, without JTA, when the framework rolls back only the transaction manager wired into the step will rollback, not the one in your dao. Furthermore, you would have to find someway to commit on the dao transaction manager as well. The only way to safely get around this is to use JTA. Since you're running out of container, the only option I can think of is Jotm.
    Hi,
    I have similar kind of situation. In my Spring Batch application, I have defined two transaction manager and in transaction manager bean declarations, I have used <qualifier> tag to differentiate these transaction manger in my transactional DAO class.

    First txn manager:
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager" >
    <property name="sessionFactory" ref="crmsSssionFactory" />
    <qualifier value="wfInternal"/>
    </bean>

    Second txn manager:
    <bean id="cddprofileTxnManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager" >
    <property name="sessionFactory" ref="cddProfileSessionFactory" />
    <qualifier value="cddProfile"/>
    </bean>

    During step execution, I need to update data into two databases.First database is same as what I use to store batch meta data. This one uses the transaction manager used by step execution which is "transactionManager". Second db one uses another transaction manager - cddprofileTxnManager. It is committing db updates in second DB, but roll back is not happening in case of exception. Is there anything I can do without using JTA?My application doesn't use any kind of Java EE container.

    Thanks,
    Sandhya

  2. #12
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    366

    Default

    Without using global transactions of some kind, you will run into the issues of having one transaction's failure not rolling back the other's.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •