Sunday, May 4, 2014

In previous post, we discussed about Queue error handler. In queue error handler rejected message is enqueued to advanced queue. In this post we will discuss about next error handler which is Custom Java error handler.

In Custom Java error handler error is handled by java framework. In this error handler we create custom java class which implements below IfaultRecoveryJavaClass interface.

package oracle.integration.platform.faultpolicy;
public interface IFaultRecoveryJavaClass
    public void handleRetrySuccess( IFaultRecoveryContext ctx);
    public String handleFault( IFaultRecoveryContext ctx);

Follow below steps to use Custom Java error for rejected file.

Custom Java Error Handler

First create a new java project in Jdeveloper. Name the project and name the default package as well.

For Custom Java error handler we need to implement IFaultRecoveryJavaClass interface and for this interface we need add fabric-runtime.jar to our project.

You can find this file at below location.


Now right click on your project and add a new Java class. Name your Java class and choose IFaultRecoveryJavaClass from Oracle à integration àplatform àfaultpolicy path.

Now add required logic to your class. For this post, we didn't add much logic; we will just show some message on console.

Now build your code and create jar file of above java class. To build jar file you need to choose “Client JAR File” and name your deployment profile.

You need to put above generated jar file to below location so that fault policy file can refer it.

Now you need to restart the SOA server.

File Polling Service

We need to use Fault Handling Framework to configure the error handler so we need to have fault-binding.xml and fault-policies.xml file.

Create a new fault-binding.xml file in the same project and add below content to it.

<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicyBindings version="2.0.1"
   <service faultPolicy="RejectedMessage">

Please note that “PollCustomerData” is name of the adapter that poll the file.

Now create a fault-policies.xml file where we add fault and required action.

For this error handler below is the format for the action.

<Action id="ora-java">
  <javaAction className="<package>.<javaClass>" defaultAction="<Action>">
    <returnValue value="SUCCESS" ref=”<Action> "/>
    <returnValue value="FAILED" ref="< Action>"/>

Please add below content to fault-policies.xml file.

<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicies xmlns="">
  <faultPolicy version="2.0.1" id="RejectedMessage">
      <!-- remote fault: -->
      <faultName xmlns:rjm=""
          <action ref="ora-java"/>
      <!--Rejected Message to AQ-->
      <Action id="ora-file">
      <Action id="ora-java">
        <javaAction className="filerejectionhandler.sampleclass"
          <returnValue value="Success" ref="ora-file"/>

Save your changes and deploy this composite to server.


Put file corrupted file to polling location. You should see log message to your console.

You also two files in rejected message folder because java function return “Success” and when it return Success “ora-file” action get invoked.

Download code from here.


Post a Comment