Reference One Flow from Another with Flow Ref (Flow Designer)
By placing a Flow Ref core component in a flow, you can run one flow from another within the same application. When Flow Ref is reached in a flow, it triggers the referenced flow. The referenced flow runs and returns the Mule event object to the original flow where execution proceeds after the Flow Ref component. Flow Ref is handy for reusing groups of components within the same Mule application.
-
The trigger card starts the main flow.
-
The Flow Ref card passes the output from the second card to the first card in the referenced flow, triggering that flow.
-
The last card in the referenced flow passes its output to the card that comes after the Flow Ref card in the main flow.
-
This card processes processes the input, creates its own output, and continues the main flow.
Procedure for creating and referencing a second flow
-
Create a second flow by following these steps:
-
Click the plus sign to the right of Flows in the Project pane..
-
In the bottom-left corner of the Let’s get started wizard, click Go straight to the canvas. The wizard creates a flow that begins with a trigger. However, a flow that you reference with a Flow Ref card must not begin with a trigger. The Flow Ref card is its trigger.
-
Rename the flow.
-
-
Return to the first flow by clicking its name under Flows in the Project pane..
-
Add a Flow Ref card at the point in the flow that you want to run the other flow. In the Flow field of the card, select the second flow. Then, click Go.
-
Add cards to the second flow, but do not add a trigger card. Ensure that the last card in this flow produces an output that you want to use as input for the card that comes after the Flow Ref card in the main flow. If the output needs to be transformed before it can be used in that next card in the main flow, use a Transform card after the Flow Ref card.