- 30 Jul 2024
- 2 Minutes to read
- Print
- DarkLight
Multi-Threading Flow Design
- Updated on 30 Jul 2024
- 2 Minutes to read
- Print
- DarkLight
Overview
Multi-Threading in Decisions refers to instances where the system executes multiple different Threads simultaneously to process batches of items within a Flow. Typically, asynchronous processes are created to run multiple independent processes, however, not all asynchronous processes run on different threads. Some run multiple synchronous processes in parallel.
Example
Configuring a Flow with the Run Flows For List [Batch Processing] Step
The Run Flows For List step utilizes a built-in Flow to process a list of items using backend parallel processing.
- In a Designer Project, click CREATE FLOW and select Flow to create a new Flow.
- Attach a Create Data step from the FAVORITE STEPS category of the Toolbox panel. Click SHOW EDITOR.
- In the Data Definitions window, enter "AccountList" under NAME, select Account as the TYPE, and check IS LIST. Click Save and close the window.
- Attach a Run Flows For List [Batch Processing] step from the Toolbox by navigating to SYSTEM > ADVANCED to the Done path.
- On the Properties panel, set the Input Type and Output Type fields to Account.
- Under the INPUTS category, map the desired AccountList to InputList. If desired, Constant map the Remove Null Results option.
- Under the FLOW category, change Run Behavior to ASyncAndWait and declare a Queue Name.
- Under Thread Count, define the desired number of Threads for the step to utilize in parallel. Then, click the EDIT [THREAD FLOW NAME] button. Note on Thread CountNote that since each individual Thread on the Run Flows For List step is a separate Flow process, running too high of a number may impact System performance. It is advised to use a lower Thread Count number such as "4" to test the impact of the step on the System.
9. From the newly opened Flow Designer, define the desired process logic; map the resulting value to INPUTS > Output Data on the End step. This example will use the Fetch Entities step to obtain Account items.
About Process LogicAs the description underneath the Action Bar suggests, the Thread processing Flow takes in the Input defined on the Run Flows For List step and processes through them to return a value for each item.10. Save and close the Flow to return to the main Flow. Configure the rest of the Flow as desired.
Configuring a Flow with the [Start Linked Flow Async] Step
The Start Linked Flow Async step is one of the most commonly utilized steps to achieve asynchronous behavior. By using this step, users may achieve Multi-Threaded processing through the use of Job Queues on the step.
- From the Flow Designer, add a [Start Linked Flow Async] step from the FLOWS category of the Toolbox tab.
- On the Properties panel under WORK QUEUE, check the Manage Execution Threads box.
- Define a new ThreadJobName.