<flow name="flow1">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
path="/source"/>
<ee:transform doc:name="Transform Message" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
Mule::lookup('flow2', {test:'hello '})]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="flow2" >
<set-payload value='#[payload.test ++ "world"]' doc:name="Set Payload" />
<logger level="INFO" doc:name="Logger" message='#[payload]'/>
</flow>
lookup
lookup(String, Any, Number)
This function enables you to execute a flow within a Mule app and retrieve the resulting payload.
It works in Mule apps that are running on Mule Runtime version 4.1.4 and later.
Similar to the Flow Reference component (recommended), the lookup
function
enables you to execute another flow within your app and to retrieve the
resulting payload. It takes the flow’s name and an input payload as
parameters. For example, lookup("anotherFlow", payload)
executes a flow
named anotherFlow
.
The function executes the specified flow using the current attributes, variables, and any error, but it only passes in the payload without any attributes or variables. Similarly, the called flow will only return its payload.
Note that lookup
function does not support calling subflows.
Always keep in mind that a functional language like DataWeave expects the
invocation of the MuleSoft recommends that you invoke flows with the Flow Ref ( |
Parameters
Name | Description |
---|---|
|
A string that identifies the target flow. |
|
The payload to send to the target flow, which can be any ( |
|
Optional. Timeout (in milliseconds) for the execution of the target flow. Defaults to |
Example
This example shows XML for two flows. The lookup
function in flow1
executes
flow2
and passes the object {test:'hello '}
as its payload to flow2
. The
Set Payload component (<set-payload/>
) in flow2
then concatenates the
value of {test:'hello '}
with the string world
to output and log
hello world
.