Add Logic, Data Transformations, Error Catching, and More to Flows (Flow Designer)
You can add cards that perform a variety of tasks to change the course of a flow, log messages, transform data, add or remove variables or payloads, and more. These cards represent the components of Mule applications and are provided by Mule Runtime.
You add card that represent components in the same way that you add other cards to a flow: by clicking the plus icon that appears after the previous card and then selecting the new card from a list, as in this image:
Flow Designer supports the following components:
- Choice
-
If you want a flow to evaluate data to determine which route among several to send the data to, use a Choice component.
Figure 2. A Choice card being used in a flow-
A card passes its output to a Choice card. The card uses an expression to evaluate the data and follows this logic:
-
If the data is x, the card routes the data to one subflow.
-
If data is y, the card routes the data to a different subflow.
-
If the data is the default value that you set in the card, the data is routed to the default subflow.
-
-
The output of the subflow is sent to the card that follows the Choice card.
-
- Flow Ref
-
By placing a Flow Ref component in a flow, you can execute one flow from another within the same application. See Reference One Flow from Another with Flow Ref.
- For-Each
-
The For-Each component splits a payload into elements and processes them one by one through the components that you place in the scope. See Process Elements in a Collection.
- Logger
-
By adding one or more Logger cards to a flow, you can monitor the flow of data through a running Mule application or even debug a Mule application by logging important information at runtime, such as error messages, status notifications, and payloads. Logger cards can be placed anywhere in a flow. You can log a string that you specify, the output of a DataWeave expression you compose with the help of the Custom Expression dialog, or any combination of strings and expressions.
The output of the Logger card goes to the Logs pane, which you can open by clicking the Logs tab in the bottom-right corner of Flow Designer.
- Parallel For-Each
-
The Parallel For-Each component splits a payload into elements and processes them simultaneously through the components that you place in the scope. See Process Elements in a Collection.
- Remove Variable
-
The Remove Variable component takes the name of a variable and removes the variable from a flow.
- Set Payload
-
The Set Payload component lets you modify the payload in the current data at a point in a flow. You can replace the payload with a string, or you can modify or replace it with a DataWeave expression.
- Set Variable
-
You can use a Set Variable component to create a variable that stores all of the output from the preceding card, stores part of the output, or manipulates the output by using functions in a DataWeave expression. You can then reuse that value in a later card by using the variable. See Store All or Part of the Output of a Card in a Variable.
- Transform
-
The Transform component converts input data to a new output structure or format.
- Try
-
You can put specific parts of a flow that are prone to errors inside Try card. If an attempt to use the part of the flow in Try fails, Try can catch the errors and apply a fix or an alternative. See Handle Errors with Try.