Hemant
Hemant

Reputation: 61

Exception Logging in Batch in Mulesoft

I have a case, where I have to log the exception error in an object in Salesforce, where I have to also take the payload (the record) for which error is there. The error here will be the record level error and I am using a batch process for this. In the screenshot there is how we are processing the exception. enter image description here

Following is the xml

    <batch:step name="HandleFailedRecords_AccountSF-360" accept-policy="ONLY_FAILURES">
                <set-payload value="#[getStepExceptions()]" doc:name="Set Payload"/>
                <foreach doc:name="For Each" collection="#[payload.values()]">
                    <set-variable variableName="Record_level_error" value="#[payload]" doc:name="Record_level_error"/>
                    <dw:transform-message doc:name="Transform Message" metadata:id="9c2e408a-f530-4ffd-a205-a787c8bc94b2">
                        <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload map
{


    SF_Object_Type__c: "Account"



}]]></dw:set-payload>
                    </dw:transform-message>
                    <sfdc:create config-ref="Salesforce__Basic_Authentication" type="Exception__c" doc:name="Salesforce">
                        <sfdc:objects ref="#[payload]"/>
                    </sfdc:create>
                    <logger message="#[payload]" level="INFO" doc:name="Logger"/>
<!--                     <flow-ref name="HandleRecordFailure" doc:name="HandleRecordFailure"/> -->

                </foreach>
            </batch:step>

        </batch:process-records>

Here I am able to get what exception I am getting, but what else I need is for which value it is getting errored out.

Upvotes: 0

Views: 751

Answers (1)

Mauro Rocco
Mauro Rocco

Reputation: 5128

Bast way to handle properly exception handling in batch processing is to do a flow-ref to a normal flow with his proper exception handling, there you will be able to handle your exception in a standard mule way and do what you need in the exception catch flow. Hope this helps

Regards

Upvotes: 1

Related Questions