I was working with sample batchJob and figured something about the BatchStepResults. Created a simple application with small payload and BatchJob, with 3 BatchSteps .
I have below payload and as per the batchJob the batchstep1 should process 4 records and Batchstep2 should be 3 and batchstep3 should be 1. But why it always 4 for each step ?
[
{
"value": "true"
},
{
"value": "false"
},
{
"value": "true"
},
{
"value": "true"
}
]
And below is the flow :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:batch="http://www.mulesoft.org/schema/mule/batch"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd">
<flow name="sampleFlow" doc:id="20a1422c-6cde-484c-855d-78910bdbf8d3" >
<scheduler doc:name="Scheduler" doc:id="983b6e46-0dab-4ca5-b4e0-82db0cda7b4e" >
<scheduling-strategy >
<fixed-frequency frequency="5" timeUnit="MINUTES"/>
</scheduling-strategy>
</scheduler>
<set-payload value='#[[
{
"value": "true"
},
{
"value": "false"
},
{
"value": "true"
},
{
"value": "true"
}
]]' doc:name="Set Payload" doc:id="d1157ac5-196e-4bbc-a4e8-1dea053c6d66" />
<batch:job jobName="sampleBatch_Job" doc:id="4437b942-4e2f-485e-8b9b-009873b44684" >
<batch:process-records >
<batch:step name="Batch_Step_1" doc:id="28651eb8-710d-46ef-8868-d98fbc8e19f2" acceptPolicy="ALL">
<logger level="INFO" doc:name="Logger" doc:id="a3001490-d798-4efc-a767-01120c63162e" message="Batch Step 1"/>
</batch:step>
<batch:step name="Batch_Step_2" doc:id="075515ed-765b-482b-b08e-aa243014ba74" acceptPolicy="ALL" acceptExpression='#[payload.value == "true"]'>
<logger level="INFO" doc:name="Logger" doc:id="977f4aa1-eb99-40a2-85a5-d709fd7757a1" message="Batch Step 2"/>
</batch:step>
<batch:step name="Batch_Step_3" doc:id="28934a79-804e-44db-8c8f-63b58a8211ee" acceptExpression='#[payload.value == "false"]' acceptPolicy="ALL">
<logger level="INFO" doc:name="Logger" doc:id="56442f2c-767c-427b-846a-23853c721c04" message="Batch Step 3"/>
</batch:step>
</batch:process-records>
<batch:on-complete >
<scatter-gather doc:name="All" doc:id="1a2c8651-0d8a-4d2c-80d1-8d7e10d1dfd8" >
<route >
<logger level="INFO" doc:name="Migration process has finished!" doc:id="ad76f37a-0bc4-4532-96bb-b2ba7a2e69cf" message="Migration process has finished!" />
</route>
<route >
<ee:transform doc:name="Prepare migration result email" doc:id="329eadd6-f103-4dce-bf23-947aa04c087d" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload.stepResults
]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="ee32daa3-2e5f-4d16-bfdf-b6933fdbc751" message="#[payload]"/>
</route>
</scatter-gather>
</batch:on-complete>
</batch:job>
</flow>
</mule>
And If you see the console :
{
"Batch_Step_1": {
"failedRecords": 0,
"successfulRecords": 4,
"exceptionSummary": {
"exceptionsCount": {
}
},
"receivedRecords": 4
},
"Batch_Step_3": {
"failedRecords": 0,
"successfulRecords": 4,
"exceptionSummary": {
"exceptionsCount": {
}
},
"receivedRecords": 4
},
"Batch_Step_2": {
"failedRecords": 0,
"successfulRecords": 4,
"exceptionSummary": {
"exceptionsCount": {
}
},
"receivedRecords": 4
}
}