About Sync and Async Sub-Flows
- Updated On 25 Jun 2020
- 3 Minutes To Read
A Sub-Flow is a Flow that runs like a Step within the course of another Flow. A Sub-Flow may also be referred to as a "Child Flow" and the primary Flow as a "Parent Flow."
A Sub-Flow may be set to run in one of two ways:
The Sync method: allows the Sub-Flow and Main Flow to run sequentially .
The Async method: allows the the primary Flow to run independently, while the Sub-Flow completes.
Each method has benefits for use in different scenarios; part of Flow design planning should be to decide which method works for a specific scenario. The key difference is that the Sync method allows the Flows to run in sequence. The Async method is designed to allow the Sub Flow to run independently of the Parent Flow. With Async, control is immediately given back to the primary Flow. The consequence of this method is that the relationship between the two Flows is "asynchronous", meaning that the Sub Flow is now an independently executing Flow and has no necessary output data to deliver to the primary Flow. Included below are a few examples and further information, regarding the different types of sub flows.
Start Linked Flow Async
In the screenshot below, the gray-colored Process Flow is a Linked Flow Async step. In this example, the Sub-Flow is designed to be ran independently from the primary Flow. The primary purpose of Async Flows is for use in instances where the Primary Flow needs to delegate a task to the Sub Flow. In this example, whenever an email is found, it is delegated to the process workflow to be filtered by a user set rule. In this case, the Async method allows the primary flow to check for Emails, while the child Flow, processes each one individually.
Below is a table description of the involved step.
|Selection Type||Decisions can run a Flow picked by a user or can be dynamically selected by runtime|
|Use Work Queue||Flows execution can be passed onto a work queue to be handled e.g. rabbitmq. For more info on work queues review worker queues workers threads|
|Manage Execution Threads||The user can select which and how many threads to run the process on|
Run Flow Async And Wait
The Run Flow Async And Wait is a check box configuration on the Run Flow step. This configuration does not run the sub Flow independent from the parent process but executes it on a separate thread. This check box configuration does three things: spawns a new process, runs the Flow on a separate thread, and returns the data to the main Flow. This is helpful in scenarios that involve multiple steps that may involve a loop or branch that would usually run synchronously, such as API calls or adding numbers. Run Flow Async and Wait allows these tasks to be executed in parallel to save time.
One difference between the Run Flow Async and Wait step and the Start Linked Flow Async is, the Run Flow Async and Wait returns data while the Start Linked Flow Async does not return data. Run Flow Async and Wait is most commonly used to assist API calls that return large amounts of data.
Go Async Flow Step
Go Async step's purpose is to move the current execution of the Flow to a different thread. This allows users more fine tuning when it comes to directing which portion of a Flow is ran Async. Users may run portions of a Flow as Async without having to move the whole process. For more information review Running Steps Asynchronously With The Go Async Component.
Sync Flows are helpful for handling processes that require the main Flow and Sub Flow to occur one after the other. For instance, within the Async Flow above, the Email handling process is split up into multiple synchronous Sub Flows depending on how the Email is evaluated. In the example below, after reaching the Email Process Folder, an Email is evaluated as either an invoice, resume, or other type, and sent to its respective Sub Flow. This allows for the ability to run a Sub Flow midway through the process, before proceeding to the next step and returning data to the parent Flow. This can be especially helpful if manager approval, or a user response is required in the process. It also allows each sequence in the Flow to be evaluated and easily troubleshooted, as they are split up separately.