问题描述
我正在尝试从CSV文件将一组帐户加载到Salesforce中.我已经配置了通常的Datamapper,带有Batch Commit的Upsert SFDC步骤和仅处理故障的Batch步骤(现在的日志).我的OnComplete有一个简单的Logger.我故意用错误的数据创建了CSV文件.我在CSV文件中有一个外部ID.
I am trying to load a set of Accounts into Salesforce from a CSV file. I have configured the usual Datamapper, Upsert SFDC Step with Batch Commit and a Batch Step that handles only failures (logs for now). My OnComplete has a simple Logger. I have intentionally created CSV with bad data. I have an external ID in the CSV.
我的要求是根据失败状态以不同方式处理失败记录.如果由于数据损坏而失败,我想停止处理记录.如果由于找不到父密钥而失败,我想重试.我的批处理步骤仅出错,不知道为什么失败.不知何故,我想将为什么失败"传递给失败处理的下一个步骤.
My requirement is to process failed records differently based on the failure status. If it failed due to Bad Data, I would like to stop processing the record. If it failed due to Parent Key not found, I would like to retry. My batch Step to process Only errors, doesn't know why it failed. Somehow, I would like to pass the "Why it failed" to my failure processing bacth step.
我确定这是一个简单的模式,但是无法弄清楚如何关联:(
I'm sure this is a simple pattern, but am unable to figure out how to correlate :(
推荐答案
在<batch:step name="Handle Failure" accept-policy="ONLY_FAILURES"/>
中,您可以使用#[getStepException()]
MEL获取异常Map.逻辑.请参阅: http://blogs.mulesoft.com/dev/mule-dev/handle-errors-batch-job/
In <batch:step name="Handle Failure" accept-policy="ONLY_FAILURES"/>
you can use #[getStepException()]
MEL to get the exception Map.Later than you can use choice component based on the exception you wants to handle the logic. Refer:http://blogs.mulesoft.com/dev/mule-dev/handle-errors-batch-job/
确保使用<batch:job name="BatchFlow" max-failed-records="-1">
,将最大失败记录设置为-1
,这样就不会停止流,并且如果任何记录中发生失败,则将其传递给仅失败"流.
Make sure using <batch:job name="BatchFlow" max-failed-records="-1">
, max failed record set to -1
, so that flow wont be stopped and if failure happens in any record it will pass it to 'only failure' flow.
<batch:job name="BatchFlow" max-failed-records="-1">
<batch:process-records>
<batch:step name="Batch_Step">
<!-- Success flow... -->
</batch:step>
<batch:step name="Handle Failure" accept-policy="ONLY_FAILURES">
<logger message="Details:#[getStepException()]" level="INFO" doc:name="Logger"/>
<!-- other logic -->
</batch:step>
</batch:process-records>
</batch:job>
这篇关于Mule Salesforce Batch中的错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!