I have 2 different datasources, one to read and another one to write results like below:
- ItemReader should get data from dataSource_1.
- ItemWriter should write data to dataSource_2.
knowing that reader and writer are in the same tasklet.
As per the documentation, we can configure a single transaction manager at tasklet
In this scenario, how do i use the transaction manager here?
I cannot rely on the container and i'm not using ORM layer (JPA..), i use direct JDBC driver to read in database 1 and write into database2.
current conf :
<bean id="dataSource1" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${batch.or.jdbc.driver}" />
<property name="url" value="${batch.or.jdbc.url}" />
<property name="username" value="${batch.or.jdbc.user}" />
<property name="password" value="${batch.or.jdbc.password}" />
</bean>
<bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${batch.caux.jdbc.driver}" />
<property name="url" value="${batch.caux.jdbc.url}" />
<property name="username" value="${batch.caux.jdbc.user}" />
<property name="password" value="${batch.caux.jdbc.password}" />
</bean>
<bean id="baseReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource1" />
</bean>
<bean id="baseWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
<property name="dataSource2" ref="dataSource2" />
<property name="sql" value="${batch.param.insert}" />
</bean>
How could i configure the JTA/XA transaction ( Atomikos ) with Spring Batch?