Thursday, April 19, 2007

CDM Ruleframe and BPEL / ESB

What is wrong with technology that is working for ages without any troubles. Basically nothing. The disadvantage is that old-fashioned technology is passed by the latest and the greatest. For example SOA and Oracle CDM Ruleframe.

Nothing is wrong with CDM Ruleframe; it's stable, logical, sits in the database and based on good-old PL/SQL.

SOA is hot, using the newest technologies as SOAP, web services, BPEL, Rules, ESB etc.

But how do you combine them? Well that's look easy, but some issues to care about.

When you use CDM Ruleframe the business rules are defined on table level. The rules are fired at once when a user does a DML on the table and commits. CDM Ruleframe will create a list of erros that does not apply to the business rules. It will create a PL/SQL table with all CDM rules that have been failed. These stacked errors should be send back to the client that was initiating the database request.

Now comes the point with SOA. In BPEL or ESB it uses the database adapter to access the Oracle database. This goes over JDBC. If an error occurs it is catch as an exception. In the exception you get the oracle error, for example ORA-20998 and an error message text. In this message text, some text is related to CDM Ruleframe. But not all the business rules are mentioned. It is up to the BPEL instance to catch the error and parse the message text to obtain the error.

A solution for this is as follows. When you want to access the database for query only, use the normal select approach. When you do an update, delete or insert call a PL/SQL package to perform the appropriate action. In this PL/SQL package you can catch the exception and collect the CDM Ruleframe errors and descriptions. This collection is formatted as an XML string in the error message text. The BPEL or ESB instance can now catch the specific oracle eroror, for example ORA-20998, and get error message text, that can be parsed as XML.

Note that the error, in XML format, send back from the Database, can be picked up via the RemoteFault exception. The error message is in the summary element. The only issue is, that is wrapped in a string. A message"Exception occurred" is put in front of the XML message and a string is appended. This can be solved by using the substring-before() and substring-after() to extract the XML result.

Post a Comment