Cyclic flows¶
A cyclic flow in a Visual Flow Creator refers to a loop within the flow structure where a process, decision or action redirects back to a previous step instead of terminating. This results in a closed-loop system that repeats until a defined exit condition is met.
The "Allow cyclic flows" can be enabled or disabled by using the toggle button at the edit flow tab properties.
Example¶
To execute a cyclic flows using delay node, follow these steps:
-
From the node palette, drag and drop the nodes with the respective palette to the working area. Connect the nodes in a flow as shown below:
-
Double click on "inject" node to edit the properties. For more information, refer to Editing nodes.
-
Double click on "function" node to edit the properties.
- Enter the "Name" as "Increment".
- Select the "Language" as "javascript".
-
Enter the "Code" as:
msg.payload++; return msg;
-
Click "Done".
- Enter the "Name" as "Increment".
-
Double click on "delay" node to edit the properties.
- Select the "Action" as "Delay each message".
- Select the "Fixed delay".
- Enter the "For" as "2 seconds".
Note
If you proceed to save and deploy the flow, a notification will be displayed with the message "Deploy failed: cycles are detected. This can lead to high compute hours consumption!"
- Select the "Action" as "Delay each message".
-
Edit the flow tab properties.
Allow cyclic flows should be enabled. -
Save and execute the flow.
The output will be displayed in the debug tab.