Sequence error handling is one of the most useful yet undervalued features of WSO2 ESB. Sequence error handling brings Java try-catch like semantics into the ESB mediation flow. However, error handling semantics of WSO2 ESB slightly varies, depending on how the sequences are setup in the ESB. This seems to generate lot of confusion around the concept of ESB error handling. For those who find it difficult to understand the error handling capabilities of WSO2 ESB, following guidelines might help:
- If a sequence explicitly defines a fault handler using the ‘onError’ attribute, the specified fault handler will be invoked, whenever an error occurs in the sequence. This is true even if the sequence is invoked by a proxy service.
- If a request arrives through the main sequence and if it happens to fail within a sequence which does not explicitly define a fault handler, the default ‘fault’ sequence will be invoked.
- If a request arrives through a proxy service and if it happens to fail within a sequence which does not explicitly define a fault handler, the fault sequence of the proxy service will be invoked. If the proxy service does not define a fault sequence, then no fault handler will be invoked.
- When there is a fault handler engaged at proxy service level, and another error handler engaged at the sequence level, the sequence level error handler gets invoked in case of an error (as per rule 1). In this case the proxy service fault sequence is ignored.
To learn more about WSO2 ESB error handling, please refer the previous installment of the tips and tricks series.