【发布时间】:2017-11-18 08:37:00
【问题描述】:
我正在使用Spring Batch3.0.7.RELEASE 版本
关于跳过我有以下几点:
<batch:chunk reader="personErrorSkipFileItemReader"
processor="personErrorSkipItemProcessor"
writer="personErrorSkipFileItemWriter"
commit-interval="100"
skip-limit="11">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.file.FlatFileParseException"/>
<batch:include class="com.manuel.jordan.batch.exception.PersonBatchException"/>
</batch:skippable-exception-classes>
</batch:chunk>
它按预期工作。
出于 logging 和 test 目的,我需要检索以下数据:
- 跳过的元素(例如 11 个中的 8 个)显示数量,例如:
-
FlatFileParseException5 -
PersonBatchException3
如果可以显示每个跳过的项目在哪个步骤和区域(读取器、处理器、写入器)中被抛出,那就更好了。
通过JobExecution,我有以下内容
List<Throwable> exceptions = jobExecution.getAllFailureExceptions();
logger.info("exceptions size: {}", exceptions.size());
for(Throwable throwable : exceptions){
logger.error("Throwable Class: {}", throwable.getClass().getSimpleName());
logger.error("{}", throwable.getMessage());
}
List<Throwable> exceptions_ = jobExecution.getFailureExceptions();
logger.info("exceptions_ size: {}", exceptions_.size());
for(Throwable throwable : exceptions_){
logger.error("Throwable Class: {}", throwable.getClass().getSimpleName());
logger.error("{}", throwable.getMessage());
}
但是两个集合的大小都大于 1 并且仅在 Job 完成时显示异常FAILED。
因为 8 Job 完成了 COMPLETED 和列表大小返回 0 的方式。
【问题讨论】:
标签: spring-batch