1

我第一次在 mule 中使用批处理,不知道如何处理批处理记录的异常。

记录输入阶段失败,但无法在输入阶段记录器和批处理步骤(失败流)记录器中捕获失败异常。也许 MEL #[inputPhaseException]本身会引发异常。

<batch:job name="Batch1" max-failed-records="-1">
    <batch:threading-profile poolExhaustedAction="WAIT"/>
    <batch:input>
        <file:inbound-endpoint path="C:\IN" responseTimeout="10000" doc:name="File"/>
 <component class="com.General" doc:name="Java"/>
        <logger message="InputPhase: #[inputPhaseException]" level="INFO" doc:name="Logger"/>
    </batch:input>
    <batch:process-records>
        <batch:step name="Batch_Step"  accept-policy="ALL" ">
            <data-mapper:transform config-ref="Pojo_To_CSV" doc:name="Pojo To CSV"/>               
            <file:outbound-endpoint path="C:\Users\OUT" outputPattern="#[function:dateStamp]_product.csv" responseTimeout="10000" doc:name="File"/>
        </batch:step>
        <batch:step name="FailureFlow" accept-policy="ONLY_FAILURES">
            <logger message="Inside Failure: #[getStepExceptions()], Loading Phase: #[failureExceptionForStep],#[inputPhaseException] " level="ERROR" doc:name="Logger"/>
        </batch:step>
    </batch:process-records>
    <batch:on-complete>
        <logger level="INFO" doc:name="Logger" message=" On Complete: #[payload.loadedRecords] Loaded Records #[payload.failedRecords] Failed Records"/>
    </batch:on-complete>
</batch:job>

批处理 MEL 是否有任何限制,只能用于输入阶段和过程记录和完成中的某些 MEL。因为我尝试将大部分 get..Exception{} 保留在失败流中,所以它会抛出错误。请建议,提前谢谢。

4

2 回答 2

1

是的..你是对的..#[inputPhaseException]导致所有问题..我已经修改了你的 Mule 流程,你可以尝试以下方法:-

<batch:job name="Batch1" max-failed-records="-1">
    <batch:threading-profile poolExhaustedAction="WAIT"/>
    <batch:input>
   <file:inbound-endpoint path="C:\IN" responseTimeout="10000" doc:name="File"/>
    <component class="com.General" doc:name="Java"/>
   </batch:input>
 <batch:process-records>
 <batch:step name="Batch_Step"  accept-policy="ALL" ">
   <data-mapper:transform config-ref="Pojo_To_CSV" doc:name="Pojo To CSV"/>               
  <file:outbound-endpoint path="C:\Users\OUT" outputPattern="#[function:dateStamp]_product.csv" responseTimeout="10000" doc:name="File"/>
 </batch:step>

<batch:step name="Batch_Failed">
<logger doc:name="Logger" level="ERROR" message="Record with the following payload has failed. Payload:: #[message.payload], Loading Phase: #[failureExceptionForStep], Inside Failure the exception is :- #[getStepExceptions()]" />
  </batch:step>
</batch:process-records>
  <batch:on-complete>
    <logger message="Number of failed Records: #[payload.failedRecords] " level="INFO" doc:name="Failed Records" />
    <logger level="INFO" doc:name="Logger" message=" Number of loadedRecord: #[payload.loadedRecords]"/>
    <logger message="Number of sucessfull Records: #[payload.successfulRecords]"    level="INFO" doc:name="Sucessfull Records" />
    <logger message="ElapsedTime #[payload.getElapsedTimeInMillis()]" level="INFO" doc:name="Elapsed Time" />
   </batch:on-complete>
 </batch:job>
于 2014-09-14T09:57:19.247 回答
1

是的,您需要在 On complete Phase 中使用它作为 finally 块来收集成功和不成功的批处理结果。 https://dzone.com/articles/handle-errors-your-batch-job%E2%80%A6

于 2015-09-26T20:09:26.313 回答