Reputation: 22506
In Spring batch you can set the transaction isolation
and propagation
like this:
<job id="someJob" xmlns="http://www.springframework.org/schema/batch">
<step id="readWriteDate">
<tasklet transaction-manager="transactionManager">
<transaction-attributes isolation="DEFAULT" propagation="REQUIRED" timeout="30"/>
<chunk reader="dbItemReader" processor="dbItemProcessor" writer="dbItemWriter"
commit-interval="2" />
</tasklet>
</step>
</job>
I cant find the java config equivalent.
Upvotes: 2
Views: 6817
Reputation: 253
It's like Michael Pralow say. Just to add a concrete example you can set the isolation level by instantiating a default transaction attribute :
DefaultTransactionAttribute transactionWithIsolationReadCommited = new DefaultTransactionAttribute(); transactionWithIsolationReadCommited.setIsolationLevel(TransactionAttribute.ISOLATION_READ_COMMITTED);
And then use it in the step builder. Hope it helps!
Upvotes: 2
Reputation: 6630
well it is there
@Configuration
public class StepWithTx {
@Autowired
private StepBuilderFactory steps;
@Bean
public Step step() throws Exception {
return steps
.get("CustomTxStep")
.<String, String>chunk(10)
.transactionAttribute(transactionAttribute...)
.reader(reader...)
.processor(processor...)
.writer(writer...)
.build();
}
}
for default implementations take a look at http://docs.spring.io/spring/docs/4.0.5.RELEASE/javadoc-api/org/springframework/transaction/interceptor/package-summary.html
Upvotes: 2