Spring batch Spring批处理:如何检索跳过的异常以进行测试
我正在使用Spring batch Spring批处理:如何检索跳过的异常以进行测试,spring-batch,Spring Batch,我正在使用springbatch3.0.7.0发行版 关于跳过我有以下几点: <batch:chunk reader="personErrorSkipFileItemReader" processor="personErrorSkipItemProcessor" writer="personErrorSkipFileItemWriter" commit-interval="100" s
springbatch
3.0.7.0发行版
关于跳过我有以下几点:
<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>
但是两个集合的大小都大于1,并且仅在作业完成时显示异常如何失败
因为8<11,作业
完成的方式完成
,列表大小返回0。实现SkipListener,它有三种回调方法
1:Onskipin过程
2:onSkipInWrite
3:onSkipInRead
它仅用于运行时目的,即方法返回void
。我需要检索该数据,用于@Test
目的,用于assertEquals
评估。您正在测试批处理的单个步骤/小任务?我想要一个步骤和所有步骤。因此,两种情况都是如此。
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());
}