Run Flow Async From Sync Step

Last Updated: 07/15/2016 Introduced in Verision: 3.2

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.

 

Example:

In this example we are going to create a Flow with two Sub-Flows. Each of the Sub-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.

addWebService

In the resulting window we Name WebService Reference, provide URL and specify WSDL. Click Ok to save and close this pop-up window.

firstWebServDefinition

Next, we add another WebService Reference in the similar manner.

secondWebServDefinition

System creates WebService References in the External Services Folder.

servicesAdded

Next, we navigate to the Designer Folder and click Create Flow on the Folder Actions Panel.

createFirstFlow

In the resulting window we Name the Flow and click Create to proceed to the Flow Designer.

nameFirstFlow

In the Flow Designer we add Forloop step from the All Steps [Catalog] > Flow Management category.

addForloopFirstFlow

Then, we select Forloop step on the workspace and configure No of Iterations value to Constant ‘50’.

configureforloopFirst

On the Next outcome from the Forloop step we add GetCountries step from the Integrations > My Integrations > WebServices > Countries category.

addGetCountries

Then, we connect steps in our Flow as following. This completes our Flow. We can save and close Flow Designer.

firstFlowCompleted

Back in the Designer Folder we Create another Flow.

createSecondFlow

Name the Flow and click Create to continue.

nameSecondFlow

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.

addForloopSecond

Then, we configure this Forloop step to Iterate 50 times.

configureForloopSecond

On the Next outcome from the Forloop step we add GetQuote step from the Integrations > My Integrations > Web Services > StockQuote category.

addGetQuote

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.

configureGetStock

Finally, back in the Designer Folder we click Create Flow to build Main Flow.

createMainFlow

Name the Flow and click Create.

nameMainFlow

In the Flow Designer we add [Pick or Create Flow] step from the Flows, Rules, Forms and Reports > Flows category.

addPickOrCreateFirst

Then, in the resulting pop-up window we Pick Get Countries Flow.

pickGetCountries

We add another [Pick or Create Flow] step…

addSecondPickOrCreate

And pick Get Stock Quote Flow that we have created previously in this tutorial.

pickStockFlow

Connect the steps in the Flow and click Debug Flow on the top panel of the Flow Designer to test the Flow.

Note that in Decisions version 3.5, you’ll need to choose Test Flow instead of Debug Flow.

3.5 Test Flow Shot

debugFlow

Debugger indicates that execution time was 38.7 seconds.

firstDebugDone

Back in the Flow Designer we select Get Countries Sub-Flow on the workspace and enable Run Flow Async And Wait configuration.

checkRunFlowFirst

Then, we do the same for the Get Stock Quote Sub-Flow.

checkRunFlowSecond

Click Debug Flow link to test Flow execution with new settings.

debugFlowSecond

This time Debugger indicates that our Flow execution took 28.4 seconds. In the second case Sub-Flows ran on the different threads.

debugSecond

 

Additional Resources