【问题标题】:Spring Batch: OnSkipInWrite prints the log twice ??? How ?Spring Batch:OnSkipInWrite 打印日志两次???如何 ?
【发布时间】:2012-07-12 09:14:30
【问题描述】:

我在执行 spring 批处理时面临一个奇怪的情况。我已将作业步骤执行配置为使用“skippable-exception-classes”作为

<step id="prepareFileStep" next="fillRecordsCounterStep">
<tasklet>
   <chunk reader="stagingIdReader" writer="customerIdRecordCompWriter" commit-interval="50" skip-limit="200">
    <streams>
         <stream ref="flatFileRecordWriter" />
    </streams>
    <skippable-exception-classes>
         <include class="java.lang.Exception" /> 
    </skippable-exception-classes>
</chunk>
<listeners>
         <listener ref="prepareFlatFileSkipListener" />
    <listener ref="prepareFlatFileStepListener" />
</listeners>
</tasklet>

而我的 onSkipInWrite() 实现为:

@OnSkipInWrite
public void onSkipInWrite(Object item, Throwable exception) {
    AppLog.warn(AppConstants.CALLER, "Skipping Customer Id:"+ item.getCustomer().getCustomerId()+"\n" + exception.toString());
}

我想知道为什么日志文件会打印两次跳过的项目,而当我调试时它只执行一次?请给我建议修复的朋友...

【问题讨论】:

    标签: spring-batch


    【解决方案1】:

    很可能是由于春季批处理块已被回滚并作为一个块项目一次重试(而不是整个块大小):

    Spring Batch: skipping during item write

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-11
      • 1970-01-01
      • 2011-08-30
      • 2011-04-26
      • 2016-04-07
      • 2017-08-10
      相关资源
      最近更新 更多