OSB Error Handling
OSB Error Handling
1|x
Guido Schmutz
Working for Trivadis for more than 15 years Oracle ACE Director for Fusion Middleware and SOA Co-Author of different books Consultant, Trainer, Software Architect for Java, Oracle, SOA and EDA Member of Trivadis Architecture Board Technology Manager @ Trivadis More than 20 years of software development experience Contact: guido.schmutz@trivadis.com Blog: http://guidoschmutz.wordpress.com Twitter: gschmutz
2|x
Agenda
1. 2. 3. 4. 5. What is Fault Handling ? Fault Handling in SOA vs. traditional systems Scenario and Patterns Implementation of Scenario Summary and Best Practices
4|x
Fault Handling
The goal of every programmer should be to write unbreakable software Extent of achievement depends on how good expected and unexpected exception conditions are handled and managed Object-oriented languages such as C++ and Java provide an efficient way for handling exceptions using constructs such as try, catch, and finally With a SOA, most of what is available at language level is still valid and usable SOA raises different challenges once starting orchestrating services and creating composite applications Prevention vs. handling
5|x
What is a Fault ?
Something happened outside normal operational activity or happy flow
Technical error Programming error Faulty operation by user Exceptional business behavior
6|x
Technical faults
Faults that service clients do not expect and cannot (easily) recover from Results of unexpected errors during runtime, e.g. null pointer errors, resources not available, and so on Often: unexpected, technical, implementation and non-recoverable
7|x
Business Fault
<wsdl:operation name="orderProduct"> <wsdl:input message="order:OrderProductRequestMessage"/> <wsdl:output message="order:OrderProductResponseMessage"/> <wsdl:fault message="order:ProductNotInStockFaultMessage" name="ProductNotInStockFault"/> <wsdl:fault message="order:CustomerNotFoundFaultMessage" name="CustomerNotFoundFault"/> </wsdl:operation> <xsd:element name="CustomerNotFoundFaultMessage"> <xsd:complexType> <xsd:sequence> <xsd:element name="CustName" type="xsd:string"/> <xsd:element name="City" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element>
8|x
9|x
Technical Fault
<wsdl:operation name="orderProduct> <wsdl:input message="order:OrderProductMessage"/> <wsdl:output message="order:OrderProductResponseMessage"/> <wsdl:fault message="order:ProductNotInStockFaultMessage" name="ProductNotInStockFault"/> <wsdl:fault message="order:CustomerNotFoundFaultMessage" name="CustomerNotFoundFault"/> </wsdl:operation>
10 | x
Agenda
1. 2. 3. 4. 5. What is Fault Handling ? Fault Handling in SOA vs. traditional systems Scenario and Patterns Implementation of Scenario Summary and Best Practices
11 | x
ESB
Implementation
Implementation
Implementation
Multiple service consumers Services part of larger unit Heterogeneous & external components Long running processes Asynchronous Timed events Often enterprise-wide Transactions
12 | x
Agenda
1. 2. 3. 4. 5. What is Fault Handling ? Fault Handling in SOA vs. traditional systems Scenario and Patterns Implementation of Scenario Summary and Best Practices
13 | x
No 7*24 avail. for single instance of credit card service Response sometimes get lost
14 | x
16 | x
17 | x
Agenda
1. 2. 3. 4. 5. What is Fault Handling ? Fault Handling in SOA vs. traditional systems Scenario and Patterns Implementation of Scenario Summary and Best Practices
18 | x
19 | x
Problem
Not to overload the old, non-scalable product system with the new demand
Solution
Use Result Caching to cache the product information (read-only operation) Use Service Throttling to limit the number of concurrent requests
20 | x
Business Service
3
Product DB
OSB
Result Cache
21 | x
Proxy Service
Business Service
Product DB
OSB
22 | x
Retry
Problem
Unstable network between us and the external services
Solution
Use Retry mechanism of OSB to try multiple times No Fault Management necessary for service consumer if network interruption is only for a short time
23 | x
OSB
5x
24 | x
Service Pooling
Problem
Credit Card Service does not guarantee 7*24 availability for one single instance
Solution
Use the multiple instances (endpoints) that the company provides and use service pooling feature of OSB No Fault Management for the service consumer if at least one endpoint is available
25 | x
OSB
26 | x
Problem
Guarantee that the message will be delivered to the order management system
Solution
Make sure that queues are available, even if the Handle Order system is not Make sure that queuing runs in the same transaction as the service consumer
27 | x
Transactions in OSB
Explanation and Demo of Transactions in OSB
28 | x
Problem
Need to return a Product No Longer Available Business Fault over an Asynchronous MEP
Solution
Design a separate Fault Message and Operation on the Callback contract (WSDL) and use that
29 | x
30 | x
Problem
Order History System not available should have no impact on Business Process
Solution
Use Mediator with Fault Management Framework to configure retry independent of availability of Order History Web Service
31 | x
32 | x
Both Product Management and Credit Card Booking can return Business Faults
Solution
Handle errors and map them to errors returned to the service consumer (i.e. the caller of the process)
33 | x
34 | x
Solution
Pick with timeout Compensate
Timeout on the Wait For Answer with a BPEL pick activity with a timeout Undo the process by doing compensation Use the BPEL compensate activity together with compensation handler to undo the Booking of the Credit Card
35 | x
36 | x
Order Processing callback message can be a Product No Longer Available Business Fault
Solution
Handle Business Fault and Compensate
Undo the process by doing compensation Use the BPEL compensate activity together with compensation handler to undo the Booking of the Credit Card
37 | x
38 | x
Solution
Non-Idempotent
To avoid BPEL calling the Book Card operation again (not really possible here), we have set the idempotent Property on the partner link to FALSE
Idempotent
39 | x
Order Handling Process (V) Generic Error Handler w. Fault Policy Framework
Problem
Unexpected (technical) error
Unexpected (technical) fault Multiple processes that deal with unexpected faults in their own way
Solution
Use fault handler mechanism to enqueue on error queue without adding process logic Create one process to listen to error queue and handle faults Retrieve process information by using (composite) sensors
40 | x
Order Handling Process (V) Generic Error Handler w. Fault Policy Framework
<faultPolicyBindings version="2.0.1"> <composite faultPolicy="GenericFaultPolicy"/> </faultPolicyBindings> <faultPolicies> <faultPolicy version="2.0.1" id="GenericFaultPolicy"> <Conditions> <action ref="GenericAction"/> </Conditions> <Actions> <Action id="GenericAction"> <javaAction className="nl.vennster.GenericHandler defaultAction=HumanIntervention"> <returnValue value="HumanIntervention" ref=" HumanIntervention"/> </javaAction> </Action> </Actions> </faultPolicy> </faultPolicies> <property name="oracle.composite.faultPolicyFile">oramds:/apps/fault-policies.xml</property> <property name="oracle.composite.faultBindingFile">oramds:/apps/fault-bindings.xml</property>
41 | x
Order Handling Process (V) Generic Error Handler w. Fault Policy Framework
Explanation of generic fault handler
42 | x
Agenda
1. 2. 3. 4. 5. What is Fault Handling ? Fault Handling in SOA vs. traditional systems Scenario and Patterns Implementation of Scenario Summary and Best Practices
43 | x
Summary
Issue Overloading product management system Credit Card Service does not guarantee 7*24 uptime due to e.g. network problems Guarantee message delivery to order management system Solution ThrottlingResult cache Muliple endpoints Service pooling Availability of queues Enqueue and dequeue in service consumer transaction Separate operation and fault message Product OSB OSB OSB (and SOA Suite for XA propagation to OSB) OSB and SOA Suite (callback contract between the two)
Returning business fault over async MEP from order management system Order history service not available Business fault handling from service to process to consumer Detect missing response message Handle product no longer available Avoid calling credit card booking twice Processes needing to deal with unexpected technical faults. All processes solving it in their own way using process logic.
Retry in Mediator using fault policy framework SOA Suite Catch faults in process and reply fault to consumer Timeout in pick activity Compensation Set non-idempotent property Fault policy frameworks, error queue, generic error handler, SOA Suite APIs & composite sensors. OSB and SOA Suite (correct contracts) SOA Suite SOA Suite SOA Suite SOA Suite
44 | x
Best Practices
Differentiate between business and technical faults Design service contracts with faults in mind: formally describe business faults in service contracts Dont use exceptions as gotos Design with criticality, likeliness to fail, and cost in mind Differentiate fault patterns in OSB and BPM/BPEL
OSB: Retry, throttling, transaction boundaries BPM/BPEL: Compensation, business fault handling, generic fault handler, timeout
Handle unexpected errors generically Make services autonomous Fault-handling on scope of services and in wider perspective
45 | x