I'm getting confused. It seems to me that there are more than one transaction managers involved.
First, there's the one for the batch database where the metadata (JobExecutions etc) are stored. I have a datasource, transaction manager, and the recommended AOP TXN configs (direct from the user manual), configured with
However, the transaction manager I'm asking about is the one configured in SimpleStepFactoryBean. When my Step is an ItemReader reading a file, should I use the same TransactionManager that points to the batch database?Code:<aop:config> <aop:advisor pointcut="execution(* org.springframework.batch.core..*Repository+.*(..))" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="create*" propagation="REQUIRES_NEW" isolation="SERIALIZABLE" /> <tx:method name="*" /> </tx:attributes> </tx:advice>
I guess you are suggesting that I use my batch database transaction manager in place of the ????? above. That's fine, I can do that. However, it seems that if I used ResourcelessTransactionManager, it doesn't affect the transactions on the batch db; those are set by the AOP and TX config above.Code:<bean id="myJob" class="org.springframework.batch.core.job.SimpleJob"> <property name="jobRepository" ref="jobRepository" /> <property name="steps"> <list> <bean id="myStep" class="org.springframework.batch.core.step.item.SimpleStepFactoryBean"> <property name="jobRepository" ref="jobRepository" /> <property name="transactionManager" ref="?????????????????????"/> <property name="itemReader" class="FlatFileItemReader"/> blah blah
Do I have that correct? I'm very sensitive about transaction configuration and want to make sure I get it right.
OTOH, if my step used a database item reader, then I'd configure a transaction manager for that particular database (or JTA) for the SimpleStepFactoryBean. Correct?
Sorry for the confusion.


Reply With Quote

