Hi,
If you are using a different transaction manager in your tasklet from the job repository like so...
I assume this will create 2 seperate transactions. And I assume the tasklet transaction is committed before the batch DAOs commit to the repository. Now what will happen if the batch DAOs fail in their update but the tasklet transaction has committed already. Will this not leave the repository showing incorrect data?Code:<job id="loadAdviceScheduleJob" xmlns="http://www.springframework.org/schema/batch"> <step id="step1"> <tasklet transaction-manager="jpaTransactionManager"> <chunk reader="AdviceScheduleReader" processor="AdviceScheduleProcessor" writer="AdviceScheduleWriter" commit-interval="1" /> </tasklet> </step> </job> <bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"> <property name="dataSource" ref="java:/interstream" /> <property name="transactionManager" ref="transactionManager" /> <property name="databaseType" value="db2" /> <property name="tablePrefix" value="batch_" /> </bean>
Can this problem be solved perhaps by having both the jobRepository and the tasklet be part of the same transaction (in the above case have them both set transactionManager property to "jpaTransactionManager").


Reply With Quote