In Mule 3, the batch input phase required a Java structure. So, for input data in formats such as XML or JSON, you first needed to transform to Java, then make DataWeave use streaming in that transformation to avoid running out of memory for large datasets.
For example, suppose you have this source data pushed to your app through an HTTP call:
Example: JSON Input Data
[
{
"name": "Luke Skywalker",
"darkSide": true
},
{
"name": "Ben Solo",
"darkSide": true
},
{
"name": "Obi-Wan Kenobi",
"darkSide": false
}
]
In Mule 3, you need to transform that JSON to Java before passing it over, something like this:
Mule 3 Example
<batch:job name="forceJob">
<<batch:input>>
<http:listener path="/forceWielders" config-ref="forceListener" />
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/java
---
payload
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<<batch:input>>
.....
</batch:job>
In Mule 4, Batch can automatically determine that the payload is a JSON array and perform the splitting on its own, for example:
Mule 4 Example
<flow name="useTheForceBatch">
<http:listener path="/forceWielders" config-ref="forceListener" />
<batch:job jobName="forceJob">
....
</batch:job>
</flow>
You no longer have to set streaming in Mule 4 because of the automatic streaming framework it uses. So, when you migrate to Mule 4, you can avoid a transformation step.