Friday, November 18, 2011

Error Handling in SOA - Part 2


Service Implementation (Realization):
In the SOA, fault should be propagated to all layer from operational to consumer layer and fault could occur at any layer and all layers should be designed in a way to handle business and technical exceptions.


In the below flow, consumer calls a business service or a process which calls respective provider. In case of happy path, based on the integration pattern service either returns response back to consumer or complete the function.In case of unhappy path, either service returns fault as part of response or SOAP fault and also calls generic fault service which takes further action based on the type and severity of fault.

Business exceptions better to be returned as part of response and technical and system unavailability exceptions better to be returned as SOAP faults.

Advantages and Disadvantages of SOAP faults VS custom SOAP body

Option
Advantage
Disadvantage
All exceptions returned as SOAP Faults
Standards-based
Recognized by SOA infrastructure
Not flexible
Can not communicate multiple exceptions
Use SOAP Faults for technical or system exceptions
Use a custom SOAP Body to return business exceptions
Technical exceptions still understood by the SOA infrastructure
Custom payload allows more expressive feedback for business exceptions, including multiple exceptions at once
Business exceptions will not be automatically handled by elements of SOA infrastructure that may be able to process business rules –though they could be configured to do so
All exceptions returned as custom SOAP Body
More expressive
Non-standard
Not recognized by SOA infrastructure

Error handling in the business process:
Fault handling:
Process invokes more than one service to perform specific business functions and fault handling is popular way to handling errors thrown by services at local or global scope. Fault handlers can be used to catch either specific faults or all faults by using a catch all block.

As a best practice create a reusable generic fault service instead of repeating the fault handling code in each process.

Compensation:
A business process invokes more than one service and each service operates within it's transaction scope if any one of the services throws a fault, fault handlers invoke compensation handlers to roll back previously committed transactions. Compensation handlers plays significant role in processes which has more than one local transaction.

Fault Aggregation:
A business process invokes more than one service and each service could throw a different fault or warning. As a best practice, process should return a comprehensive faults to the consumer instead of latest fault information.

Error handling in Mediation or Service Bus:
Mediation or service bus also uses fault handlers to take appropriate actions or forward the fault to corresponding end point. service bus can also perform transformations on the fault to convert them into meaningful fault before returning to consumer. service bus either returns the fault to consumer or forward to a different service to perform appropriate action.
------------------------------------------------------------------------------------------------------------------------
In my next blog, I'll cover how fault handling can be implemented using Oracle SOA Suite.

No comments:

Post a Comment