Do While
Discover more about the Do While component and how to use it on the Digibee Integration Platform.
Last updated
Discover more about the Do While component and how to use it on the Digibee Integration Platform.
Last updated
Do While allows the construction of blocks in loop inside a pipeline. It's part of a set of components that work with subpipelines to execute their functions.
Take a look at the configuration parameters of the component. Parameters supported by Double Braces expressions are marked with (DB)
.
Iteration
Defines the maximum number of times a loop is executed (it's possible to stop the loop before this number is reached).
10
Integer
Timeout
Maximum time the loop must execute.
300000
Integer
Loop Index
If the option is activated, a “loopIndex”
property will be inserted in the presented message at each loop iteration and will inform the current iteration index (1, 2, 3, …).
False
Boolean
Interrupt Loop On Error
If the option is activated, an error occurred inside an iteration will cause the loop interruption as a whole. Otherwise, the loop will continue from the next iteration.
True
Boolean
To work with this type of component, it's important to keep in mind:
Subpipeline defined in the onProcess block: the pipeline defined in this block is deployed at each loop iteration. Therefore, if the loop has 10 iterations, the subpipeline is executed 10 times.
Subpipeline defined in the onException block: the pipeline defined in this block is deployed whenever a loop iteration results in error.
To define the subpipeline to be deployed at each iteration, just click on the onProcess icon of the Do While component:
When clicking on this icon, a subpipeline will be created (or shown, if it already exists). Then all you have to do is build the desired flow according to the execution need of each iteration.
The input of this pipeline will be fed with the message that comes before Do While. This will happen in the #1 loop execution. For the other iterations, the presented message will be the final message of the previous iteration and so on. If Loop Index is activated, a loopIndex
property will be inserted in the message informing the current iteration.
To interrupt a loop before the maximum number of defined iterations, just inform a "loopBreak: true"
property in the end of the iteration. If the property is found, the loop will be broken.
A way to inform this property is by using the JSON Generator component, which allows the definition of arbitrary JSONs in the pipeline flow.
The standar behavior of Do While is to interrupt the loop if an error is found. Errors are atypical situations in the deployment of a pipeline that end up generating a stop. For example, the use of an Assert component causes an error in the pipeline when the assertion condition isn't met. Other error situations happen when components are used with the enabled Fail On Error configuration.
As previously explained, it's possible to define a subpipeline to handle errors. The definition of this subpipeline is made through the onException icon of the Do While component:
The input of this subpipeline will be fed with an error message, which will inform what happened to the iteration and the index of the iteration (loopIndex
) that caused the failure.
the subpipeline will be immediately interrupted;
an error will be thrown from the Do While component;
no other component will be invoked after Do While.
the subpipeline will be immediately interrupted;
the subpipeline defined in onException will be executed and its output will feed the component that follows Do While;
the component that follows Do While will be invoked.
the iteration where the error occurred will be interrupted;
a standard error message will be informed in the input of the following iteration and the loop will keep being normally executed.
the iteration where the error occurred will be interrupted;
the subpipeline defined in onException will be executed and its output will feed the following iteration;
the loop will keep being normally executed.
the loop will be interrupted;
the error will be thrown for the following component which the Do While component is associated to;
if Do While is in the pipeline main flow, then the pipeline will be interrupted;
if Do While is inside a component that has a subpipeline, then the onException subpipeline will be invoked and the error will be informed in this pipeline input.