Friday, January 2, 2015

Oracle SOA - Mediator Error Handling highlights

Mediator Error Handling

Business fault:

Business faults are application-specific and are explicitly defined in the service WSDL file. You can handle business faults by defining the fault handlers in Oracle JDeveloper at design time.


<faultName xmlns:ns1="http://xmlns.oracle.com/Customer"
 name="ns1:InvalidCustomer"> <!-- Qname of Business/SOAP fault -->
       <condition>
         <test>
contains($fault.<PART_NAME>/custid, 1011)
 </test>
<!-- xpath condition based on fault payload -->
         <action ref="ora-retry"/>
       </condition>
   </faultName>
 
When a reference service returns a business fault, the fault can be handled in the Mediator service component. The returned fault can be forwarded to another component, redirected to an adapter service such as a file adapter, or an event can be raised. However, if both a fault policy and fault handler are defined for a business fault, then the fault policy takes precedence over the fault handler. In such a case, the fault handlers in the Mediator service component are ignored, if the fault policy is successfully executed.


 System Fault:

System faults occur because of some problem in the underlying system such as a network not being available. Mediator provides fault policy-based error handling for system faults.

Fault policies are not supported for the following:
  • Callback execution failures(Asynchronous and one-way Mediator components cannot handle system faults thrown from other SOA Suite components, such as a BPEL business process.)
  • Fault Handler action failures
  • Resequencer failures

The Mediator service engine throws only one fault, namely {http://schemas.oracle.com/mediator/faults}mediatorFault. Every Mediator fault is wrapped into this fault. The errors or faults generated by a Mediator can be captured by using the format shown in

<faultName xmlns:medns="http://schemas.oracle.com/mediator/faults" name="medns:mediatorFault">
<!-- mediatorFault is a bucket for all the mediator faults -->
     <condition>
       <test>
 contains($fault.mediatorErrorCode, "TYPE_FATAL_MESH")
 </test> 
<!-- Captures TYPE_FATAL_MESH errors -->
       <action ref="ora-retry"/>
     </condition>
   </faultName>

Fault policies for sequential routing rules are handled differently than for parallel routing rules

Sr No Sequencial Routing Rule Parallel Routing Rule
1. Transaction rolled back even if there is fault policy present Transaction does not rolled back if there is fault policy present
2. Fault return to the caller if there is no fault ploicy Human intervention action is deault action if there is no fault policy
3. Only Abort, Rethrow and Java actions are supported in fault policy and the specified actions are executed immediately in the caller's thread. Only Human Intervention, Retry, abort and Java action supported in fault policy
4. Mediator messages are not persisted in sequential routing Messages are persisted

1 comment: