How to Work with Multipart Request Messages

21 Using Oracle Mediator Error Handling 21-1 21 Using Oracle Mediator Error Handling This chapter describes how to handle errors with Oracle Mediator. This chapter includes the following sections: ■ Section 21.1, Introduction to Oracle Mediator Error Handling ■ Section 21.2, Using Error Handling with Oracle Mediator ■ Section 21.3, Fault Recovery Using Oracle Enterprise Manager Fusion Middleware Control ■ Section 21.4, Error Handling XML Schema Definition Files

21.1 Introduction to Oracle Mediator Error Handling

Oracle Mediator provides sophisticated error handling capabilities that enable you to configure an Oracle Mediator service component for error occurrences and corresponding corrective actions. Error handling enables an Oracle Mediator to handle errors that occur during the processing of messages and also the exceptions returned by outside web services. You can handle both business faults and system faults with Oracle Mediator. 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. System faults occur because of some problem in the underlying system such as a network not being available. Oracle Mediator provides fault policy-based error handling for system faults. Fault policies enable you to handle errors automatically or through human intervention. Oracle Mediator fault policy-based error handling consists of the following three components: ■ Fault policies ■ Fault bindings ■ Error groups

21.1.1 Fault Policies

A fault policy defines error conditions and corresponding actions. Fault policies are defined in the fault-policies.xml file. The fault-policies.xml file should be created based on the XML schema defined in Section 21.4.1, Schema Definition File for fault-policies.xml. 21-2 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite A sample fault policy file is shown in Example 21–1 : Example 21–1 Sample Fault Policy File ?xml version=1.0 encoding=UTF-8? faultPolicies faultPolicy version=2.0.1 id=CRM_ServiceFaults Conditions faultName xmlns:medns=http:schemas.oracle.commediatorfaults name=medns:mediatorFault condition testcontainsfault.mediatorErrorCode, TYPE_FATAL_MESHtest action ref=ora-retry condition faultName Conditions Actions Action id=ora-retry retry retryCount3retryCount retryInterval2retryInterval exponentialBackoff retryFailureAction ref=ora-java retrySuccessAction ref=ora-terminate retry Action Actions faultPolicy faultPolicies The two components of the fault policy conditions and actions are described in the following sections.

21.1.1.1 Conditions

Conditions identify error or fault conditions along with a reference to the actions to be taken. You can use conditions to identify the action to be taken when a particular error or fault condition occurs. For example, for a particular error occurring because of a service not being available, you can perform an action such as a retry. Similarly, for another error occurring because of the failure of Schematron validation, you can perform the action of human intervention. This fault can be recovered manually by editing the payload and then resubmitting it through Oracle Enterprise Manager Fusion Middleware Control. Conditions are defined in the fault-policies.xml file, as shown in Example 21–2 : Example 21–2 Conditions Conditions faultName xmlns:medns=http:schemas.oracle.commediatorfaults Note: Fault policies are applicable to parallel routing rules only. For sequential routing rules, the fault goes back to the caller. It is the responsibility of the caller to handle the fault. If the caller is an adapter, then you can define rejection handlers on the inbound adapter to take care of the messages that error out that is, the rejected messages. For more information about rejection handlers, see the Oracle Fusion Middleware Users Guide for Technology Adapters.