The when expressions need to be changed from MEL to DataWeave. This also mean that you can leverage DataWeave’s ability to interpret any format to avoid unnecessary convertions. For example, suppose a flow in which a JSON document representing a user is posted through HTTP and you want to check if the person is underage:
Mule 3 Example: MEL
<flow name="checkAge">
<http:listener path="person" method="POST" config-ref="http" />
<json:json-to-object-transformer />
<choice>
<when expression="#[payload.age > 21]">
<logger message="adult" />
</when>
<otherwise>
<logger message="underage" />
</otherwise>
</choice>
</flow>
With Mule 4, you don’t need to worry about JSON or Java formats and just do:
Mule 4 Example: DataWeave 2
<flow name="checkAge">
<http:listener path="person" method="POST" config-ref="http" />
<choice>
<when expression="#[payload.age > 21]">
<logger message="adult" />
</when>
<otherwise>
<logger message="underage" />
</otherwise>
</choice>
</flow>