事务模型描述
1、step之间事务独立
2、step划分成多个chunk执行,chunk事务彼此独立,互不影响;chunk开始开启一个事务,正常结束提交
图-job总体事务
图-step内部事务
事务提交&回滚
1、事务提交条件:chunk执行正常,未抛RuntimeExecption
2、默认情况下,Reader、Processor、Writer抛出未捕获RuntimeException,当前chunk事务回滚,step失败,job失败
3、通过以下配置,保证出现异常时,事务不回滚,事务继续提交:
<batch:tasklet>
<batch:no-rollback-exception-classes>
</batch:no-rollback-exception-classes>
</batch:tasklet>
4、事务配置.通过以下配置,改变事务行为
<batch:tasklet>
</batch:tasklet>
默认配置:DEFAULT+REQUIRED
参数配置影响
1、任务恢复
</batch:job>
2、跳过
<batch:chunk skip-limit="20">
<batch:skippable-exception-classes>
</batch:skippable-exception-classes>
</batch:chunk>
或者
<batch:chunk skip-policy="defSkipPolicy">
</batch:chunk>
a、ItemProcessor处理中跳过
b、ItemWriter处理中跳过
3、重试
<batch:chunk retry-limit="20">
<batch:retryable-exception-classes>
</batch:retryable-exception-classes>
</batch:chunk>
或者
<batch:chunk retry-policy="defRetryPolicy">
</batch:chunk>
重试次数达到或者重试策略不满足时,step失败,job失败
4、reader-transactional-queue&processor-transactional
a、reader-transactional-queue,默认false,设置为true代表read资源具备事务特性,chunk事务回滚时,资源回滚。出现异常导致重复读取并处理,注意幂等性问题
b、processor-transactional,默认true,即writer失败时,processor重复执行,需要注意幂等性问题;设置false,即writer失败时,processor不再执行
处理组件事务
一点点建议
原文:https://www.cnblogs.com/nizuimeiabc1/p/9360353.html