Search This Blog

Sunday, August 9, 2015

JMS Queue -- Message Rollback

CASE:
One of most commonly used mechanism/component in many of the integration projects is JMS queue to send the messages back and forth among participating applications at the same time they will run into different issues like configuring JMS queue or constructing JMS Adapter etc... and the current topic is a bit different from our regular issues. 

In real time integration's most of the call outs to web services will occurs on a particular event in that case sending the payload to web service ends source application responsibility after that it is receiver web service responsibility to hold the received payload and ensure that data is delivered successfully.

Scenario:
One of the scenario I have faced was source application delivers the data to my web-service upon an event and I need to enrich this and have to send across multiple participating applications in this integration where we need to convert the data into corresponding format which can be accepted by destination systems.

In this scenario, as soon as I receive the data from source application I used to store data in JMS queue which is created on Weblogic server where SOA resides.

Now the problem is after de-queue the data from this queue any of the end-systems may be down in that case my data will be sent to only to the applications which were up and running i.e. I can't keep all the participating applications in sync.

So, to over come this problem, I selected a synchronous BPEL service which as soon as de-queue the data from above mentioned JMS queue I will check all the participating end-system's are up and running or not.
Here you need to have a switch condition to decide whether data has to proceed further with processing or rollback to JMS queue.

If end-systems are up proceed with data enrichment and send data to end-systems finally you can reply some dummy value to JMS queue.
otherwise, if end-system is down have a throw activity which will rollback the data to JMS queue.

example:- 

step1: check end system web service is up or not using java activity.

        String serviceURL=(String)getVariableData("EndPoint");    
        java.net.URL serverAddress=null;         
        java.net.HttpURLConnection connection = null;         
        int st=0;         
        try {         
            serverAddress = new java.net.URL(serviceURL);         
            connection = (java.net.HttpURLConnection)serverAddress.openConnection();         
            connection.setRequestMethod("POST");         
            connection.setDoOutput(true);         
            connection.setReadTimeout(10000000);           
            connection.connect();         
            st=connection.getResponseCode();      
            st=connection.getContentLength();      
            setVariableData("endPointStatus",st);         
        } catch (Exception e) {         
            e.printStackTrace();         
            setVariableData("endPointStatus",st);         
        }

step2: Take the output into a local bpel variable using assing activity

Step3: Switch condition to decide which flow to choose.
If endsystem returns "-1" use "throw activity" which will rollback the data to JMS queue.
otherwise, data process further to deliver to end-systems.

Note:- 
1) This is as part of my requirement I have chosen this approach, this still have some limitations which I am fine with.

2) Thanks to Srinivas Adusumalli for helping me on this.

Thursday, August 6, 2015

CSF Key Creation and Usage

Case: Creating CSF key in Oracle SOA 11g

Usage: credentials for HTTP basic authentication can be used, updated run time and managed easily

In the world of integration projects, it is very common to invoke the 3rd party web service into your web service
i.e. when your service is acting as a caller service and calling service will accept your request only upon authenticating your identity then we can pass the credentials in different ways.

CSF Key, also know as Credentials Store Factory - Key, One of the best way of sending credentials in the header along with your actual request  in Oracle SOA is using CSF Key.

Case:
Most of the web service providers expect authentication before addressing your request.
Example, in one of my projects we need to invoke Fusion Customer Hub web service which is https secured service expecting both certificate on your server and basic http authentication credentials.


Creating CSF key:
Creating CSF Key is quite easy.
Login to Oracle SOA EM console -- http://servername:port/EM

Expand the Weblogic Domain in left side panel.

Right click on SOA11TEST_domain (your SOA domain)

Select Security/Credentials as shown below.

Which will open a new window in the right side panel as shown below.

You can click on "Create Key" option to create a new CSF key and if you want to see existing CSF key's click on "oracle.wsm.security"

After click on "Create key" select "oracle.wsm.security" as shown below. 


You can give values as below.
key (key name) --  which we will use in our code to refer this key values while invoking the web service.
User Name -- Give required username which is provided by service provider.
Password -- Give required password which is provided by service provider.
confirm password and give description about the key and purpose.

And click on "Ok".

Ex:- 



Now you are ready with CSF Key.

How to Use:
During development of caller web service in Jdeveloper.
On the SCA Composite window
After creating partner link for the web service you are planing to invoke (calling web service partner link)
You can right click on the partner link where you have to pass the credentials, which will open the window as shown below and select the Security policy as shown below by clicking "+" sign at the Security section level.


Upon completion of adding the owsm security policy click on edit option (pencil icon) which is just next to the '+' sign you used above. Shown below.



Click on "ok" and "ok" on both the windows which will enable the WSM policy and also adds the CSF key credentials as shown below.

How to check if it is properly added or not.
Go to SCA Composite as shown below and go to respective reference XML tags to show if the policy and key added properly or not.





Which will completes the steps to create CSF key in Oracle SOA server and how to use it in your code.

And once after the CSF key is created in future though the credentials changed you can go to EM console and you can edit the corresponding CSF key with new credentials which will be ready available run time.

Thursday, May 27, 2010

Agile on Weblogic server -- JMS Destination configuration

In this blog I am about to explain about a patch for D2R i.e. Agile to E-biz pip where Agile is on Weblogic server.
While doing ACS “Agile Content Services” setup in Agile we need to follow the “JMS Destination” configuration which is to pass the data from Agile to our SOA server.
Steps given in installation and configuration document for D2R is in the assumption of Agile is on OC4J server but if your Agile is on Weblogic Server our problem will come into the picture.

For that Oracle has given the patch - p9010426_9300_WINNT.zip where you need to follow some steps.

Here I am explaining about the steps involved about applying the patch and generally what problems we will face while applying the patch and workarounds.

Follow the steps to apply the patch.
1. Patch 9010426 (Only for WebLogic platform)

1.1 Install and Configure Patch 9010426

1) Stop the agile server
2)Extract the zip file p9010426_9300_WINNT.zip
3)Open command prompt and Navigate to the extracted files folder
4)Set the Environment variable JAVA_HOME to the jdk installed with the agile 9.3 PLM
5) Execute Install_Patch.bat and you should see INSTALLATION SUCCESSFULL and BUILD SUCCESSFULL

6)Now start the agile server
7) Navigate to the \agileDomain\lib directory and verify that you see the following files aqapi.jar, aqjms.properties, WLS103AQJMSStartupClass.jar
8)Open the aqjms.properties file and edit the information (SOA DB) for Server, Port and DBInstance

Server= your hostname or ipaddress
Port= soaDBport number
DBInstance=SID

Save the file and close it

9)In the command prompt,navigate to the \agileDomain\lib and execute the following command

This command will creates the files 1) aqjms_user.properties and 2) aqjms.dat
in the \agileDomain\lib folder

C:\bea\jdk160_05\bin\java –cp.;WLS103AQJMSStartupClass.jar;C:\bea\wlserver_10.3\server\lib\weblogic.jar;%classpath% com.oracle.oems.weblogic.AQJMSPasswordUtility -username PLMECOQueue -password PLMECOQueue

Bold letters in the above command will change based on your environment and installed drive.
Most of the cases it is “PLMECOQueue” only.


Sometime while executing this command you might face some issue like given below
unrecognized option: -username
could not create the Java virtual machine.


Solution:
That might be because of the spaces in the command. In case try with giving space before and remove after “–cp “in the command


Also sometimes you may face the error –
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: ûcp


Solution :
In case, you need to give “-” in “-cp” part of the above command from the key which is next to “Numlock” button on your keyboard (i.e. sometimes it will give problem using the key next to “0” in the keyboard)


10) Check that the following files get created under the \agileDomain\lib
aqjms_user.properties, aqjms.dat

11) Navigate to \agileDomain\config and edit the file config.xml. Add the following lines before the tag . Edit the entries marked in bold as per your environment. For target specify the agile server name.

<startup-class>
<name><aqstartupclass></name>
<target>agilePCServer</target>
<deployment-order>1000</DEPLOYMENT-ORDER>
<class-name>com.oracle.oems.weblogic.AQJMSStartupClass</CLASS-NAME> <arguments>AQJMSPropertiesFile=aqjms.properties,AQJMSPasswordFile=aqjms_user.properties,AQJMSSecretFile=aqjms.dat,AQJMSConfigDirectory=D:/AgileBuilds/Agile93WLS/agileDomain/lib</arguments>
<failure-is-fatal>true</FAILURE-IS-FATAL>
<load-before-app-deployments>true</LOAD-BEFORE-APP-DEPLOYMENTS>
<load-before-app-activation>true</LOAD-BEFORE-APP-ACTIVATION>
</STARTUP-CLASS>

Note: agilePCServer in the above tags is your agile server name.


12) Modify your startAgile.cmd (\agileDomain\bin) to add the system properties below.

-Doracle.jms.useEmulatedXA=false -Doracle.jms.useNativeXA=true



You can add it just before %DEBUG_OPTS% weblogic.server gotofinish


13)Start the Agile Server using the startAgile.cmd file. This will now load the startup class which will complete the binding that you configured earlier.

1
.2 Create Agile destination in ACS (only Weblogic)

1. Login to java client and configure a new destination and test the destination to end the configuration