Wednesday, February 16, 2011

WSO2 ESB Tips & Tricks 06: Error Handling Semantics

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:
  1. 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.
  2. 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.
  3. 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.
  4. 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.


Vijay Pandey said...

i am new in WSO2 please guide me how can we use Sequences and Registry



Hiranya Jayathilaka said...

ESB samples 9 and 10 in the samples guide will help you

Faisal Shaik said...

As per oracle soa we can handle errors in 3 ways
1.try ,catch
2. compensation handler
3.writing the policy.xml,bindings .xml
previously i worked for that Now i move to WSO2 SOA
How many ways we have to handle a Error in WSO2 ESB

Hiranya Jayathilaka said...

Implementing a fault sequence is by far the most widely used method. That gives you try-catch semantics. There are other advanced methods like defining a dead letter channel, automatic retrying etc but those are highly specialized cases.