Subpipeline is a subprocess from the main pipeline. Subpipelines are necessarily connected and triggered from a component in the main process, such as “For Each”.
Let's imagine a process called Client Data Validation. This process has the REST endpoint data and then verifies if each client register has the necessary information. To iterate for this collection of registers, we'll use the component "For Each" (Process Customer Records).
Every time a component with the capacity to iterate by collection is added to a pipeline, 2 subpipelines are created: onProcess and onException.
The flow that processes each item of the collection is implemented in this subpipeline. It has its own Canvas, which is accessed through the menu of the component:
In the case of the Client Data Validation process, the onProcess subpipeline will treat all the registers of the clients collection individually, checking if each of them has the attribute Date of Birth filled:
By the end of each onProcess subpipeline deployment, a "success" attribute is returned, indicating if the deployment was successful or not. By default, this attribute is returned with the "false" value. That way, you must explicitly inform when the deployment occurs as expected.
A successful answer will be returned in the Client Data Validation process when the attribute Date of Birth is filled. The answer is generated by the JSON Generator (Success) component as shown below:
If the Date of Birth attribute is empty, the JSON Generator (Failure) returns the attribute with the "false" value:
In this case, an exception is generated through the Assert (Internal Error) component:
The Fail On Error attribute indicates that, if the Condition of the Assert component isn't met, the deployment of the pipeline flow will be interrupted and an exception will be thrown.
When the deployment derives from a component that is inside a subpipeline, the onException subpipeline deployment is started. On the other hand, if the deployment happens in a component that is in the main pipeline, the pipeline deployment will be interrupted with the error.
The flow that treats a deployment in the deployment of the onProcess subpipeline is implemented in this subpipeline. The Canvas can be accessed through the menu of the component:
When the onException is executed in the Client Data Validation process, a call to a REST endpoint is made, registering the incident and generating an error message in the Platform log.
Even though the use of onException is optional, we strongly recommend it. Many components of the Platform support the Fail On Error attribute and allow error treatment and recovery strategies to be implemented through onException, making the pipeline much more robust and resilient.
To understand the composition of a pipeline, read the Pipeline article.