ah, i see. I got what you meant, Anatoly, Thanks.
We deploy app to the production env & dryrun the batch and collect the statistics.
We keep the app running in dryrun for a couple of days/weeks to observe the statistics.
When we think everything is ok, we change one of the value in the app, then start persisting data.
So, I wrote a delegator class which wraps PlatformTransactionManager and controls commit/rollback.
impl
Code:
public class RollbackTransactionManager implements PlatformTransactionManager {
private PlatformTransactionManager transactionManager;
private boolean doRollback;
public void commit(TransactionStatus status) throws TransactionException {
if (doRollback) {
transactionManager.rollback(status);
} else {
transactionManager.commit(status);
}
}
......
}
job config file
Code:
<!-- provides a real txmanager to job repository -->
<batch:job-repository id="jobRepository" transaction-manager="transactionManager"/>
<batch:job id="job">
<batch:step id="step">
<!-- provides a wrapped txmanager -->
<batch:tasklet transaction-manager="rollbackAwareTxManager">
<batch:chunk reader="sampleReader" writer="sampleWriter"/>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="rollbackAwareTxManager" class="com.foobar.RollbackTransactionManager">
<property name="transactionManager" ref="transactionManager" />
</bean>