Consider a message coming from an HTTP request, which we want to redirect to a third system, only that adding a state query param which is to be extracted using a secondary flow called stateLookup. Because you don’t want to lose the original payload or headers, you need to extract this value without affecting the original message. The Enricher calls out to the enrichment resource with the current message (containing the zip code), then enriches the current message with the result.
Mule 3 example
<flow name="orderProcessingFlow">
<http:listener .../>
<enricher target="#[variable:state]">
<flow-ref name="stateLookup"/>
</enricher>
<http:request config-ref="config" path="state" method="POST">
<http:request-builder>
<http:query-param paramName="state" value="#[flowVars.state]" />
</http:request-builder>
</http:request>
</flow>
In Mule 4, you can simply use the target parameter in the <flow-ref> operation:
Mule 4 example
<flow name="orderProcessingFlow">
<http:listener .../>
<flow-ref name="stateLookup" target="state" />
<http:request config-ref="config" path="state" method="POST">
<http:query-params>
#[{'state' : vars.state}]
</http:query-params>
</http:request>
</flow>