Spring批处理 - 如何xml confissionure“容错”

问题描述:

我该如何配置(基于xml)Spring容错工作,即“容错”即。将在SkipPolicy上履行失败?Spring批处理 - 如何xml confissionure“容错”

我发现了一些JavaConfig文档,但没有一个用于基于xml的配置。

到目前为止,它在第一次写入失败时中止作业。

Günni

+2

使用跳过限制或重试限制(http://docs.spring.io/spring-batch/trunk/reference/html/configureStep.html) – 2014-10-03 22:39:32

+0

事实证明,春天是按照广告的方式工作,只要您配置事务管理器正确。这是一个噩梦的人想出来......感谢大家的帮助 – Guenni 2014-10-05 22:27:29

Spring Batch的调用跳过策略当一个项目的读者,处理器或作家抛出异常。 你不能在编写器级别定义它,所以我建议你指定你自己的异常,所以它只会来自编写器;

你可以使用默认的Spring Batch的政策withing块元素,并与跳跃限制使用 即

<step id="stepWithSkipPolicy"> 
<tasklet> 
    <chunk reader="reader" writer="writer" commit-interval="100" skip-limit="10"/> 
     <batch:skippable-exception-classes> 
      <batch:include class="MyWriterException"/> 
     </batch:skippable-exception-classes> 
    </tasklet> 
</step> 

您可以在org.springframework.batch.core.step.skip找到额外的跳过政策

可以使用在chunck级跳策略属性将您自己的策略

<step id="stepWithSkipPolicy"> 
<tasklet> 
    <chunk reader="reader" writer="writer" commit-interval="100" 
      skip-policy="mySkipPolicy" /> 
    </tasklet> 
</step> 

只要将自己的跳过策略插入到步骤中,跳过限制属性和可跳过异常类 标记就不会起作用。