大家好,又见面了,我是你们的朋友全栈君。
总体事务

图-step内部事务满足自定义完成策略
<batch:tasklet><batch:chunk /><batch:no-rollback-exception-classes><batch:include class="com.xx.batch.DefRuntimeException"/></batch:no-rollback-exception-classes></batch:tasklet>
<batch:tasklet>
<batch:transaction-attributes isolation="READ_COMMITTED" propagation="REQUIRES_NEW" timeout="300"/>
<batch:chunk reader="defItemReader" processor="defItemProcessor" writer="defItemWriter" commit-interval="10"/>
</batch:tasklet>
DEFAULT+REQUIRED
任务恢复
<batch:job id="jobId" restartable="true">
</batch:job>
AbstractItemCountingItemStreamItemReader类,所以
默认具备读取恢复能力
<batch:chunk skip-limit="20"><batch:skippable-exception-classes><batch:include class="com.xx.batch.ExceptionClass" /></batch:skippable-exception-classes></batch:chunk>
<batch:chunk skip-policy="defSkipPolicy">
</batch:chunk>
如果存在业务逻辑,注意幂等性问题
<batch:chunk retry-limit="20">
<batch:retryable-exception-classes>
<batch:include class="com.xx.batch.ExceptionClass" />
</batch:retryable-exception-classes>
</batch:chunk>
<batch:chunk retry-policy="defRetryPolicy">
</batch:chunk>

图-job执行阶段轨迹&事务
注意:ItemReadeListener、ItemProcessListener、ItemWriteListener所有监听方法均在chunk事务当中执行,所以,如果在这些监听方法里面要处理好业务事务与chunk事务的关系,最好将业务事务设置为独立REQUIRE_NEW特性,
避免相互影响
因此,如果在批量处理过程中需要做些业务逻辑,那么业务逻辑的实现需要与它彼此独立,尽量不要在batch的处理过程中耦合业务逻辑,原因如下:
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/146269.html原文链接:https://javaforall.net
