Retry Loop

The flow detailed below and downloadable as an importable workflow is not a full use case but is a short overview of how to implement a simple standard retry loop within the Webex Connect platform

Flow Overview

An overview of the flow is below.

Start Node (Configure Webhook) - The configure webhook node is the start node for this sample and will take a very simple payload of error, this can be set to 1/0 or true/false depending on the test to be executed.

Branch Node - This node does not need to exist and exists only for this testable sample workflow. The node takes the place of the action you wish to loop around. the node will branch on success/error based on the input error value passed in. Usually this node would be a HTTP Node, custom integration node or similar and the loop will be triggered off the back of an error.

Retry - The node which controls the retry loop, further details below on specifics for this node.

Delay - A node which will delay the flow for the given delay period calculated from the input array.

Fail retries and End - A node to act as an end point for the flow in an error situation. In a real life situation this may include logging to external sources, reporting or another failover condition.

Success and End - A node to act as an end point for the flow in a success situation.

image

The below configuration Values should exist in the custom parameters.

image

Configure Webhook

The configure webhook node is the start node for this sample and will take a very simple payload of error, this can be set to 1/0 or true/false depending on the test to be executed.


{
 "error": ""
}

image

Branch

This node does not need to exist and exists only for this testable sample workflow. The node takes the place of the action you wish to loop around. the node will branch on success/error based on the input error value passed in. Usually this node would be a HTTP Node, custom integration node or similar and the loop will be triggered off the back of an error.

image

Retry Evaluate Node

The node which controls the retry loop.

The below code performs the following actions.

ln1 - sets retryAttempt to the number set either previously or from the default setting of 0. ln2 - sets the retryArrayObject from the object stored in the custom parameters using the JSON.parse method.

ln4-ln7 - If the number of retry attemps is greater than or equal to the length of the retryArray object it will set retryAttempts to zero to reset this count in case of future use and return the literal "BREAK" to exit on the "BREAK" branch. ln7-ln10 - Else set retryAttemp to ++ , add one, and set the retryTimer to the position in the array the current attemp is at. Arrays are zero based, so the first item has index 0, the second index 1 etc. Also returns the literal "RETRY" to exit on the "RETRY" branch.

var retryAttempt = parseInt(retryAttempt);
var retryArrayObj = JSON.parse('$(retryArray)');

if (retryAttempt >= retryArrayObj.length) {
    retryAttempt = 0;
    "BREAK"
} else {
    retryTimer = retryArrayObj[retryAttempt];
    retryAttempt++;
    "RETRY"
}

image

The retry evaluate node has the below transition actions to populate the descriptive logs with the values when it exits the node. This is so you can validate the properties to ensure exit.

image

Delay

The delay node has 1 setting, this setting is the retryTimer as populated by the Retry Evaluate node. The retry timer will not be exact and looses accuracy further below 10 seconds so should not be used for exact to the millisecond/second actions.

image

Fail retries and End

A node to act as an end point for the flow in an error situation. In a real life situation this may include logging to external sources, reporting or another failover condition.

Success and End

A node to act as an end point for the flow in a success situation.

Flow Download

Retry Loop