Understand what they are and how they work.
Subpipelines are subflows of the pipeline that are connected and triggered by a component of the main flow, for example, For Each.
Imagine a process called "Validation of Client Data". This process receives client data through the REST endpoint and then verifies that each client record contains the required data.
To iterate through the collection of records, we'll use the For Each (Processes clients records) component.
Each time a component that can iterate through collections is added to a pipeline, 2 subpipelines are created: onProcess and onException.
This subpipeline implements the subflow that processes each element in the collection. The onProcess can be accessed from the component's menu:
In the case of the "Validation of Client Data" process, the onProcess subpipeline handles all the records of the clients collection individually and checks whether the "Date of birth" attribute is filled in each of them:
At the end of each execution of the onProcess subpipeline, a success attribute is returned indicating whether the execution succeeded or failed. By default, this attribute is returned with a value "false". Thus, you must explicitly indicate when the execution went as expected.
In the "Validation of Client Data" process, the following success message is returned by the JSON Generator (Success) component when the "Date of birth" attribute is filled in:
If the "Date of birth" attribute is empty, the JSON Generator (Failure) component returns the attribute with the value "false":
In this case, an exception is generated via the Assert (Internal Error) component:
The Fail On Error attribute indicates that execution of the pipeline flow will be interrupted and an exception will be thrown if the Assert component condition is not validated.
Note: If the exception is thrown by a component of a subpipeline, the execution of the onException subpipeline is started. On the other hand, if the exception is thrown by a component in the main flow, the error causes the execution to stop.
This subpipeline implements the flow that handles an exception to the execution of the onProcess subpipeline. The onException can be accessed from the component's menu:
When the onException is executed in the “Validation of Client Data” process, a request is made to a REST endpoint that records the incident and generates an error message in the Pipeline Logs page.
Note: The use of onException is optional, but strongly recommended. Several Digibee Integration Platform components support the Fail On Error attribute and allow error handling and recovery strategies to be implemented through onException, making the pipeline much more robust and resilient.