Using the Run Flow Async and Wait Property
- Updated on 31 Jul 2015
- 3 minutes to read
This tutorial demonstrates how to use Run Flow Async And Wait configuration for the Sub-Flow steps. Run Flow Async And Wait is an advanced configuration and should be used with caution. It is important to understand in what cases this feature should be used. When this setting is on, Sub-Flow step will run Async (like Fire and Forget) but Parent Flow will wait on the results. For example, this can be used if Parent Flow has to make several expensive Web Service calls.
In this example we are going to create a Flow with two Sub-Flows. Each of theSub-Flows will make Web Service calls. We are going to compare Flow execution times with and without Run Flow Async And Wait setting.
First, we need to add couple Web Service References. Navigate to the System > Integrations > External Services folder and click Add WebService Reference on the Folder Actions Panel.
In the resulting window we Name WebService Reference , provide URL and specify WSDL . Click Ok to save and close this pop-up window.
Next, we add another WebService Reference in the similar manner.
System creates WebService References in the External Services Folder.
Next, we navigate to the Designer Folder and click Create Flow on the Folder Actions Panel.
In the resulting window we Name the Flow and click Create to proceed to the Flow Designer.
In the Flow Designer we add Forloop step from the All Steps [Catalog] > Flow Management category.
Then, we select Forloop step on the workspace and configure No of Iterations value to Constant ‘50’.
On the Next outcome from the Forloop step we add GetCountries step from the Integrations > My Integrations > WebServices > Countries category.
Then, we connect steps in our Flow as following. This completes our Flow . We can save and close Flow Designer.
Back in the Designer Folder we Create another Flow .
Name the Flow and click Create to continue.
This Flow is going to be designed similar to the First Flow that we created in this tutorial. We add Forloop step from the All Steps [Catalog] > Flow Management category.
Then, we configure this Forloop step to Iterate 50 times.
On the Next outcome from the Forloop step we add GetQuote step from theIntegrations > My Integrations > Web Services > StockQuote category.
Next, connect steps in the Flow as on the following figure. Then, we define Constant symbol Input for the GetStock step. This completes our Flow . We save and close Flow Designer.
Finally, back in the Designer Folder we click Create Flow to build Main Flow.
Name the Flow and click Create .
In the Flow Designer we add [Pick or Create Flow] step from the Flows, Rules, Forms and Reports > Flows category.
Then, in the resulting pop-up window we Pick Get Countries Flow.
We add another [Pick or Create Flow] step…
And pick Get Stock Quote Flow that we have created previously in this tutorial.
Connect the steps in the Flow and click Debug Flow on the top panel of the Flow Designer to test the Flow .
Debugger indicates that execution time was 37 seconds.
Back in the Flow Designer we select Get Countries Sub-Flow on the workspace and enable Run Flow Async And Wait configuration.
Then, we do the same for the Get Stock Quote Sub-Flow.
Click Debug Flow link to test Flow execution with new settings.
This time Debugger indicates that our Flow execution took 31 seconds. In the second case Sub-Flows ran on the different threads.