0

春のバッチを実行している間、私は奇妙な状況に直面しています。「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());
}

ログ ファイルがスキップされた項目を 2 回出力したのはなぜでしょうか。修正する友達を教えてください...

4

1 に答える 1

1

ほとんどの場合、春のバッチ チャンクがロールバックされ、(チャンク サイズ全体ではなく) 一度に 1 つのチャンク アイテムとして再試行されたことが原因です。

Spring Batch: アイテム書き込み中のスキップ

于 2012-08-30T13:25:37.677 に答える