Thursday, June 26, 2014

Practise BPEL Process and XSLT Programming

How did you develope your BPEL processes and XML transformation? What is the best approach for development with BEPL and XSLT in Oracle SOA Suite? Should we put most effort on BPEL processes to manipulate the data or should we put more time on XSLT to transform the data? What is a good practice for BPEL + XSLT programming?

When I ask myself these questions, I couldn't give myself an truly answer. It is really difficult to have a clear standard for these programming. But I definitely have my own 2 standards in my daily work.

  1. For business orchestration, 100% sure we should use BPEL to make it works
  2. For data manipulate or transformation, I will prefer to use XSLT to massage them
But they are not always working. As, sometimes, the XSLT may not be able to complete what you want and you may have to leverage the BEPL or even the Embeded Java. 

Recently, I worked on a project and the product of vender is using UTC time to save the datetime. But client is using local time without timezone. In the BPEL processes, I have to convert the local time to UTC time. But it is not just timezone issue and I need to handle daylight saving too. In summer, the offset is 4hrs (Toronto), but it is 5hrs in winter. I looked for a solution and tried many times, but it didn't work. At the begining, I used the current time function in XSLT to get the offset. But when I test the dates which crosses over the daylight saving change day, it will not work. What should I do?

Later, I have to leverage the power of Java. Don't laugh at me, I know it is a little of ugly to introduce the embeded Java in BEPL process. But only several lines of Java code really make the time calculation working. 

I never advocate the purity of codes, but I would insist my these 2 standards to make the code clear and maintainable and keep the intrusive codes as less as possible. Just like many years ago, when I was using Hibernate, I used it to handle CRUD and small volume of data access and never refuse to use stored procedures to handle big volume of data for efficiency.

What I believed is we should use the right tool or approach to do the right thing.

Friday, March 07, 2014

SOA - Handle timeout in a synchronous BPEL processes with Correlation Sets



Recently, I worked on a project and need to handle webservice call time-out issue. In current solution, the developers used JMS Queue to handle the time-out issue. The flow can be described as the following steps.

  1. When our webservice gets a request from client, the message will be put in the request queue
  2. a MDB picks the message and initializes an webservice call to an scheduling system to make an appointment
  3. After the MDB gets the response, it puts the response message into response queue.
  4. The caller  process picks up the message and returns to client.
That the happy path, but sometimes you will need a long time to get the response back caused by the slow network or the busy scheduling system. As the client can't wait for too long and the socket connection has been closed when the response comes back. At this time, the response message will sit in the response queue. When it gets expired, it will be moved to an error queue. The Error handling MDB will initialize a call to the scheduling system to cancel the booked appointment.

Now, we prepared to move the application from WLI to SOA Suite and were asked to handle the same issue in SOA Suite. What I thought is there are 2 approaches to do it.

  1. Implement the exact same logic with BPEL and JMS Queue.
  2. Implement a much smarter process to return the response to client utilizing the BPEL correlation.

I did some research on the internet and didn't get a happy answer on how to implement second solution. But theoretically, I thought BPEL should be able to complete this job as it is statful and supports long run transaction. I didn't give up and kept to look for any sample I could find on the internet and books. Eventually, I found some helpful information from Oracle SOA Suite 11g Developers Cookbook and a blog on AMIS Technology Blog, which are listed in the references. Based on these pieces information, I began my adventure.

At the beginning, I just followed the book as the book mentioned the correlation implementation is different from SOA Suite 11.1.1.6 and didn't looked at the log in detail. I copied the schema and wsdl from the sample code of Oracle SOA Suite 11g Developers Cookbook, then modified them to add an response for the service.  But the code didn't work when I completed and it could not accept any further call with the OnMessage activity.

Later, I began to look at the blog line by line and tried to find useful information. Fortunately, it is really helpful and I found I need to add correlation on the response too. After that, it still didn't work. Then I added an reply before the invocation of third part webservice. Woo! What a magic it is. it worked eventually.

References:
Use BPEL Correlation Sets for repeated (synchronous) access to long running BPEL processes
Chapter 5 of Oracle SOA Suite 11g Developers Cookbook (P96)

SOA - DB connection issue in SOA env.

Today, I installed SOA Suite and OSB on a machine. Then I created a domain with OSB, SOA Suite and BAM support. When I started the weblogic service, I always got the follow error and the server could not be started.

The error is 
Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 0 bytes.  The connection has been terminated.
    at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
    at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
    at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:322)
    at java.sql.DriverManager.getConnection(DriverManager.java:273)
    at jdbc.JDBCSample.main(JDBCSample.java:19).

Searched on the internet, but didn't get any useful info. But it looks like a connectionissue. Then I opened the config file wlsbjmsrpDataSource-jdbc.xml and found the follow funny configuration.

jdbc:derby://localhost:1521/XE;create=true;ServerName=localhost;databaseName=XE
org.apache.derby.jdbc.ClientDriver

The driver is used derby, but the database was pointed to Oracle XE. Really have no idea why got such a config. Whatever, I modified it to the follow and the server started properly.

jdbc:oracle:thin:@localhost:1521/XE
oracle.jdbc.xa.client.OracleXADataSource