Wednesday, May 14, 2014

SOA 11g - Pick Activity In BPEL

Pick activity is very important in BPEL. We use this activity in following cases.
  •  When we call asynchronous service and we need response back in certain time frame otherwise we need to throw exception.
  • When we want to have multiple entry point for any composite. E.g. when we want our process when it is invoked by client or when any message is put to JMS queue by client.


Pick activity has two branches, OnMessage Branch and OnAlarm Branch which are explained below.

Out of these two branches, only one will execute.

OnMessage is same as Receive activity. It is used when we need to receive message from external system.




OnAlarm branch is used when we want to specify expiry time.


Wednesday, May 7, 2014

SOA 11g - catchjava.lang.UnsupportedOperationException: Remote JDBC disabled

We usually got below error when we try to connect to remote system using JDBC drivers.



To resolve this you need to change property in setDomainEnv file.

Go to that file, you can find this file at below location.

${Middleware_Home}/user_projects/domains/${domain_name}/bin


Open this file and search for “WLS_JDBC_REMOTE_ENABLED” property. Earlier it was set to false, now change it to true.

Monday, May 5, 2014

SOA 11g- RejectedMsgRecoveryContext cannot be cast to com.collaxa.cube.engine.fp.BPELFaultRecoveryContextImpl

Sometime we encounter below error when use Custom Java handler inside fault policies.



There are certain points that need to be keep in mind when using Custom Java Handler inside fault policies to handle different type of error.

We usually use Custom Java handler when we handle error for File/FTP adapter or BPEL/Mediator.

Note here that there are different context for file/ftp and BPEL/Mediator. If you use file/ftp context for BPEL/Mediator then you will above error.

File Adapter

In case of file adapter, we get “oracle.integration.platform.faulthandling.recovery.RejectedMsgRecoveryContext” so we have to use this context only.

BPEL

In case of BPEL, we get “com.collaxa.cube.engine.fp.BPELFaultRecoveryContextImpl” so we have to use this context only.


If I try to use below statement for File adapter then you will get above “can not be cast” error.
        BPELFaultRecoveryContextImpl bpelCtx =           (BPELFaultRecoveryContextImpl)iFaultRecoveryContext;




SOA 11g - java.lang.NoClassDefFoundError comcollaxacubeenginefpBPELFaultRecoveryContextImpl

Sometime we face below error when we try to implement Custom Java error handler inside fault policy file.

Error: java.lang.NoClassDefFoundError comcollaxacubeenginefpBPELFaultRecoveryCont
extImpl

Reason: Reason behind this error is that you are putting your custom jar file at wrong location.

Solution: You need to put your custom jar file at below location and follow below steps.
1.    Go to ${Middleware_Home}\Oracle_SOA1\soa\modules\oracle.soa.ext_11.1.1.
2.    Copy your custom jar file here.
3.    Run ant.

4.    Restart your all servers.



Sunday, May 4, 2014

SOA 11g - File rejection Handler Part- 5 (Custom Java Handler for File Adapter)

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.

C:\Oracle\Middleware\Oracle_SOA1\soa\modules\oracle.soa.fabric_11.1.1



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.
C:\Oracle\Middleware\user_projects\domains\base_domain\lib

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"
                     xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <service faultPolicy="RejectedMessage">
      <name>PollCustomerData</name>
   </service>
</faultPolicyBindings>

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>"/>
  </javaAction>
</Action>

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

<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
  <faultPolicy version="2.0.1" id="RejectedMessage">
    <Conditions>
      <!-- remote fault: -->
      <faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
                 name="rjm:PollCustomerData">
        <condition>
          <action ref="ora-java"/>
        </condition>
      </faultName>
    </Conditions>
    <Actions>
      <!--Rejected Message to AQ-->
      <Action id="ora-file">
        <fileAction>
          <location>D:\rejectedmsgs</location>
          <fileName>rejmsg_%ID%_%TIMESTAMP%.xml</fileName>
        </fileAction>
      </Action>
      <Action id="ora-java">
        <javaAction className="filerejectionhandler.sampleclass"
                    defaultAction="ora-terminate">
          <returnValue value="Success" ref="ora-file"/>
        </javaAction>
      </Action>
    </Actions>
  </faultPolicy>
</faultPolicies>




Save your changes and deploy this composite to server.

Testing

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.


Saturday, May 3, 2014

SOA 11g - java.sql.SQLException: ORA-25215: user_data type and queue type do not match

Sometime, we see below error when we try to enqueue message to AQ (Advanced Queue). I faced this error when I used file rejection handler to enqueue rejected message to AQ.



Cause: When we try to send the message to advanced queue which is not compatible i.e.  User tries to send an object to queue which is different as that of queue.






 Solution: To make it work, I removed the object type and re-created the queue table as RAW type.


Please refer my previous post to see how to create AQ table as RAW type.


SOA 11g - File Rejection Handler Part- 4 (JMS Queue Handler for File Adapter)

In previous post, we discussed about web service handler. In web service handler rejected message is handled by web service. In this post we will discuss about next error handler which is Advanced Queue error handler.

In Queue error handler rejected message is enqueued to advanced queue.

Please note that your AQ table type is RAW type otherwise you will see below error.

java.sql.SQLException: ORA-25215: user_data type and queue type do not match.



Follow below steps to use Advanced Queue error handler for rejected file.

Queue Error Handler

First you need to have advanced queue in oracle which will take the rejected message. Refer my previous post where I explain how to create advanced queue in Oracle.

For this post we will use below AQ and AQ table which we created in previous post.

Advanced Queue- SampleAQ
Advanced Queue Table - SampleAQTable

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"
                     xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <service faultPolicy="RejectedMessage">
      <name>PollCustomerData</name>
   </service>
</faultPolicyBindings>

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-queue">
  <enqueue uri="QueueURI"/> <!-- QueueURI format  -
jdbc:oracle:thin:@<host>:<port>:<sid>#<un>/<pw>#queue -->
</Action>

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

<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
  <faultPolicy version="2.0.1" id="RejectedMessage">
    <Conditions>
      <!-- remote fault: -->
      <faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
                 name="rjm:PollCustomerData">
        <condition>
          <action ref="ora-queue"/>
        </condition>
      </faultName>
    </Conditions>
    <Actions>
      <!--Rejected Message to AQ-->
      <Action id="ora-queue">
        <enqueue uri="jdbc:oracle:thin:@localhost:1521:xe#sys as sysdba/oracle#SampleAQ"/>
      </Action>
    </Actions>
  </faultPolicy>
</faultPolicies>



Save your changes and deploy this composite to server.

Testing

Put file corrupted file to polling location. You should see new entry in SampleAQTable.




 Download code from here.


Next post explains about next error handler, File rejection Handler - Custom Java error handler for File Adapter.

SOA 11g - Create Advance Queue (AQ)

In this post, I will show you how to create advanced queue in Oracle which is compatible with Oracle SOA.

You can either use sys user or create different user for this advanced queue. If you plan to use another user then you need to provide AQ privileges to that user.

Follow below steps to create new user and provide AQ privileges to that user.

sqlplus system/password as SYSDBA
                     
GRANT connect, resource TO aquser IDENTIFIED BY aquser;
GRANT aq_user_role TO aquser;
GRANT execute ON sys.dbms_aqadm TO aquser;
GRANT execute ON sys.dbms_aq TO aquser;
GRANT execute ON sys.dbms_aqin TO aquser;
GRANT execute ON sys.dbms_aqjms TO aquser;

To create advanced queue you need to run below command.

Create Advanced Queue

BEGIN
    DBMS_AQADM.CREATE_QUEUE_TABLE(
            QUEUE_TABLE =>'SampleAQTable',
            QUEUE_PAYLOAD_TYPE =>'RAW',
            COMPATIBLE => '10.0');
END;

Create Advanced Queue Table

BEGIN
    DBMS_AQADM.CREATE_QUEUE(
            QUEUE_NAME =>'SampleAQ',
            QUEUE_TABLE =>'SampleAQTable');
END;


You need to start the queue before using it.

Start Advanced Queue

BEGIN
DBMS_AQADM.START_QUEUE (
QUEUE_NAME => 'SampleAQ');
END;

Execute below command to check the queue and table.

SELECT object_name, object_type FROM user_objects where object_name like '%SAMPLE%';


Your queue is ready to integrate with Oracle SOA.




Run below command if you want to drop AQ and AQ table.

First you need to stop the queue then only you can drop it.

Stop advanced queue

BEGIN
    DBMS_AQADM.STOP_QUEUE (
    QUEUE_NAME => 'SampleAQ');
END;

Drop advanced queue

BEGIN
    DBMS_AQADM.DROP_QUEUE (
    QUEUE_NAME => 'SampleAQ');
END;

Drop advanced queue table

BEGIN
    DBMS_AQADM.DROP_QUEUE_TABLE (
    QUEUE_TABLE => 'SampleAQTable');

END;



Friday, May 2, 2014

SOA 11g - File Rejection Handler Part -3 (Web Service Handler for File Adapter)

In previous post, we discussed file error handler which handle the rejected file and put that to custom folder with custom file name. In this post we will discuss about next error handler which is web service handler.

In web service handler rejected message is handled by web service, there is predefined WSDL interface which have to use to create web service which will handle the rejected message.

Below is the schema that we need to use for that web service.

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://xmlns.oracle.com/pcbpel/errorHandling"
        xmlns:tns="http://xmlns.oracle.com/pcbpel/errorHandling"
        elementFormDefault="qualified">
  <element name="RejectedMessage" type="tns:RejectedMessageType"/>
    <complexType name="RejectedMessageType">
        <sequence>
       <!-- base64 encoded strings" -->
          <element name="MessageHeader" type="string"/>
          <element name="MessagePayload" type="string"/>
          <element name="RejectionReason" type="string"/>
        </sequence>
      <attribute name="RejectionId" type="string"/>
    </complexType>
</schema>

Follow below steps to use web service handler for rejected file.

Web Service Handler Service

First create a web service for web service handler which will handle rejected file. Use above mentioned schema and make sure web service has only one port type and one input operation.


You can add required logic to it. For this post, we will not add any logic to it.

Save the composite and deploy it to the server.

Below is the endpoint of web service handler.





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"
                     xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <service faultPolicy="RejectedMessage">
      <name>PollCustomerData</name>
   </service>
</faultPolicyBindings>

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-ws">
  <invokeWS uri="WebServiceURI"/>
<!-- format - <Absolute wsdl path>|service name|port name -->
</Action>


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


<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
  <faultPolicy version="2.0.1" id="RejectedMessage">
    <Conditions>
      <!-- remote fault: -->
      <faultName xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
                 name="rjm:PollCustomerData">
        <condition>
          <action ref="ora-ws"/>
        </condition>
      </faultName>
    </Conditions>
    <Actions>
      <!--invoke web service for rejected messag-->
      <Action id="ora-ws">
        <invokeWS uri="http://localhost:8001/soa-infra/services/default/WebServiceHandler/webservicehandlerbpel_client_ep?WSDL|webservicehandlerbpel_client_ep|WebServiceHandlerBPEL_pt"/>
      </Action>
    </Actions>
  </faultPolicy>
</faultPolicies>



Save your changes and deploy this composite to server.


Testing

Put file corrupted file to polling location. You should see new instance of web service handler.




Download sample code from here.


Next post explains about next error handler, File rejection Handler- JMS queue error Handler for File Adapter.