Spring Batch - 异常不可跳过

时间:2014-03-10 15:13:38

标签: java sql spring batch-processing spring-batch

这是我的代码:

<chunk reader="READER" writer="WRITER"
    commit-interval="1000" skip-limit="1000">
    <skippable-exception-classes>
        <include class="java.lang.Exception"/>
    </skippable-exception-classes>
</chunk>

记录Stacktrace:

  

org.springframework.batch.retry.ExhaustedRetryException: Retry exhausted after last attempt in recovery path, but exception is not skippable.; nested exception is org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [ MERGE INTO FHD_GTGT_GEN_TXN_X TXN USING (

我想了解是什么:“异常不可跳过”,如何使这段代码工作?目前,该步骤失败导致工作终止。

Spring Batch: spring-batch-2.1.xsd

1 个答案:

答案 0 :(得分:1)

异常是SQL异常 - SQLException:

org.springframework.jdbc.UncategorizedSQLException 

您的跳过规则仅涉及Java.lang异常。如果您还希望跳过SQL异常,则还必须将其包含在跳过规则中。在堆栈跟踪的某处,它将为您提供确切的异常,如果您希望跳过遇到该异常的记录,则可以包含该异常。建议您的跳过异常更具体,以免跳过所有错误。

<chunk reader="READER" writer="WRITER"
 commit-interval="1000" skip-limit="1000">
  <skippable-exception-classes>
     <include class="java.lang.Exception"/>
     <include class="java.sql.SQLException"/>
  </skippable-exception-classes>
</chunk>