Skip to main content

Apply Business Rules engine to Message Broking in Oracle Service Bus

Material of this post was published on oracle magazine (russian edition), see the following link to read the article.
From the last few weeks i am working with Oracle OSB. In this post i want to share my some experince to apply Business rules engine to message broking in OSB. The full article has been written in Russian language for Oracle Magazine and will add the link soon after publish.
From the few years we have been familliar with Business rules and java rules engine API(JSR-94) and successfully usees business rules on many project. From the view of OSB - sometimes it's very important to separate the business logic or policy implementions from the OSB proxy service. In any corporate business logic or business policy could change often, specially in tele-communication sector and stock exchanges.
This post is not to discuss about when and why to use Business rules engine rather than how to use it with OSB to implement and separate business policy for message broking.
Here i will discuss about ilog Jrules and it's funtionallity to integrate with OSB.
In the market of BRMS - Ilog Jrules is one of the best and costly implementation of business rules, however open source Drools or Jess is not a toy at all.
Ilog Jrules gave opportunaty to call business rules via web service or ormi protocol (Also jboss t3 and much more).
Actually it's very easy to develop web service as a client which will invoke business rules or rule set.
Ilog jrules offeres plugin in eclipse to create and deploy business rules as web service.
Here below is fragment of code to invoke business rules for web service.
Properties jndi = new Properties();
jndi.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
jndi.put(Context.PROVIDER_URL,"ormi://172.24.10.74:12401/paksession");
jndi.put(Context.SECURITY_PRINCIPAL,"bres");
jndi.put(Context.SECURITY_CREDENTIALS,"bres");

/* Jboss configuration
System.setProperty("java.naming.provider.url","jnp://172.24.10.74");
System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
*/
try {
IlrRuleSessionProvider rsProvider = new IlrRuleSessionProviderFactory.Builder(jndi).build();
IlrStatelessRuleSession session = rsProvider.createStatelessRuleSession();
// prepare a new request
String rulesPath = "/UFTPNRuleAppS/1.0/RosFinMonitoringReportUPFT/1.0";
IlrSessionRequest request = new IlrSessionRequest(rulesPath);
// Set the input parameters for the execution of the rules
IlrSessionExecutionSettings sessionExecutionSettings = request.getExecutionSettings();
IlrSessionParameters inputParameters = sessionExecutionSettings.getInputParameters();
inputParameters.setParameter("paramOperation", 1429691l);
request.getSessionDescriptor().enableTrace();
//set the rule Set parameter in the request
IlrSessionResponse response = null;
IlrSessionExecutionResult executionResult = null;
response = session.executeRules(request);

executionResult = response.getExecutionResult();

System.out.println("FiredRule:"+ executionResult.getNumRulesFired());
ArrayList firedRules = executionResult.getRulesFired();
for(int i=0, cnt=firedRules.size(); i < cnt; i++){
//ilog.rules.engine.IlrRule rule = (IlrRule) firedRules.get(i);
System.out.println("Fired Rule Name:"+firedRules.get(i));
}

} catch (IlrRuleSessionCreationException e) {
e.printStackTrace();
} catch(RemoteException e){
e.printStackTrace();
} catch(IlrRuleSessionException e){
e.printStackTrace();
} /*catch(NamingException e){
e.printStackTrace();
}*/
In the part of OSB, have a severel way to use Business rules in proxy service. 1) Define a business service with the WSDL of the web service of business rules, which will have higher level of abstraction of the buseiness rule. Assaign the input message and invoke the service and assaign the result in any local variable for further using. Here is nothing special than any other call of service. 2) Create a java project first to invoke j2ee call to Business rule. Implements the invoke such as above in any static method. Compile and create artifact(a jar file) from the project and import or copy the jar file into the OSB project. Define a java call out node in proxy service of OSB and prepare input and output message to call the business service. In the such way we can use business rule or policy in OSB. In Ilog there is another type of service named decision service, it's simply a web service with JMX manegment. In the following see the rules engine invocation in action: Also follow the following articles to know much more about business rules invocation: http://www.oracle.com/technology/pub/articles/bpel_cookbook/geminiuc.html http://www-128.ibm.com/developerworks/java/library/j-drools/

Comments

Popular posts from this blog

8 things every developer should know about the Apache Ignite caching

Any technology, no matter how advanced it is, will not be able to solve your problems if you implement it improperly. Caching, precisely when it comes to the use of a distributed caching, can only accelerate your application with the proper use and configurations of it. From this point of view, Apache Ignite is no different, and there are a few steps to consider before using it in the production environment. In this article, we describe various technics that can help you to plan and adequately use of Apache Ignite as cutting-edge caching technology. Do proper capacity planning before using Ignite cluster. Do paperwork for understanding the size of the cache, number of CPUs or how many JVMs will be required. Let’s assume that you are using Hibernate as an ORM in 10 application servers and wish to use Ignite as an L2 cache. Calculate the total memory usages and the number of Ignite nodes you have to need for maintaining your SLA. An incorrect number of the Ignite nodes can become a b...

Quick start with In memory Data Grid, Apache Ignite

UP1: For complete quick start guide, see also the sample chapter of the book "High performance in-memory computing with Apache Ignite" here . Even you can find the sample examples from the GitHub repository . IMDG or In memory data grid is not an in-memory relational database, an NoSQL database or a relational database. It is a different breed of software datastore. The data model is distributed across many servers in a single location or across multiple locations. This distribution is known as a data fabric. This distributed model is known as a ‘shared nothing’ architecture. IMDG has following characteristics: All servers can be active in each site. All data is stored in the RAM of the servers. Servers can be added or removed non-disruptively, to increase the amount of RAM available. The data model is non-relational and is object-based.  Distributed applications written on the platform independent language. The data fabric is resilient, allowing non-disruptive au...

Analyse with ANT - a sonar way

After the Javaone conference in Moscow, i have found some free hours to play with Sonar . Here is a quick steps to start analyzing with ANT projects. Sonar provides Analyze with ANT document to play around with ANT, i have just modify some parts. Here is it. 1) Download the Sonar Ant Task and put it in your ${ANT_HOME}/lib directory 2) Modify your ANT build.xml as follows: <?xml version = '1.0' encoding = 'windows-1251'?> <project name="abc" default="build" basedir="."> <!-- Define the Sonar task if this hasn't been done in a common script --> <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> <classpath path="E:\java\ant\1.8\apache-ant-1.8.0\lib" /> </taskdef> <!-- Out-of-the-box those parameters are optional --> <property name="sonar.jdbc.url" value="jdbc:oracle:thin:@xyz/sirius.xyz" /> <property na...