B2B Integration 10.4 | Administering and Monitoring B2B Transactions | Service Development Help | Failure Handling in Flow Services Using the TRY, CATCH, and FINALLY Steps | Usage Patterns for Failure Handling | TRY-CATCH-FINALLY
 
TRY-CATCH-FINALLY
The TRY-CATCH-FINALLY usage pattern is a combination of TRY-CATCH and TRY-FINALLY. A TRY-CATCH-FINALLY consists of a TRY step that contains logic to be attempted, followed by one or more CATCH steps to handle any failure that occurs and execute recovery logic. This is followed by a single FINALLY step to perform any clean up.
Integration Server executes a TRY-CATCH-FINALLY in the following way:
1. Integration Server executes the steps contained in the TRY step sequentially until all steps have been executed or one of the steps fails. When a failure occurs in one of the child steps, Integration Server does not execute the remainder of the child steps. Instead Integration Server exits the TRY step.
2. Integration Server evaluates the first CATCH step that follows the TRY step to determine if the CATCH step handles the failure. The failures that a CATCH step handles depends on the combined values of the Failures and Selection properties of the CATCH step.
*If the first CATCH step handles the failure, then Integration Server executes the CATCH step. Integration Server ignores any subsequent CATCH steps associated with the TRY step.
When a CATCH step completes normally, the failure is no longer uncaught. Integration Server discards any pending exception.
When a CATCH step fails, the new failure becomes the pending failure,
*If the first CATCH step does not handles the failure, Integration Server evaluates the next CATCH step if one exists.
Integration Server repeats step 2 for subsequent CATCH steps associated with the TRY step until a CATCH step handles the failure or no CATCH steps remain. If no CATCH step handles the failure from the TRY step, then Integration Server continues to the FINALY step.
3. Integration Server executes the FINALLY step.
4. If the FINALLY step completes normally, Integration Server propagates any existing uncaught failure from the TRY step to the parent flow step. If the CATCH or FINALLY steps complete abruptly Integration Server does not propagate the uncaught failure. If the FINALLY step fails, the failure becomes the new uncaught failure.
In the following example flow service, a TRY step executes the pub.file:getFile service followed by the pub.xml:getXMLNodeIterator service. If either service throws a service exception, Integration Server exits the TRY step and evaluates the CATCH step to determine if it handles the thrown exception. Regardless of the success of the TRY step, whether the CATCH step handles the thrown exception, or whether a failure occurs during execution of the CATCH step, Integration Server executes the FINALLY step which includes the pub.io:close service to close an open InputStream.
Example of a TRY-CATCH-FINALLY

Copyright © 2016- 2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release