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

Tip: SQL client for Apache Ignite cache

A new SQL client configuration described in  The Apache Ignite book . If it got you interested, check out the rest of the book for more helpful information. Apache Ignite provides SQL queries execution on the caches, SQL syntax is an ANSI-99 compliant. Therefore, you can execute SQL queries against any caches from any SQL client which supports JDBC thin client. This section is for those, who feels comfortable with SQL rather than execute a bunch of code to retrieve data from the cache. Apache Ignite out of the box shipped with JDBC driver that allows you to connect to Ignite caches and retrieve distributed data from the cache using standard SQL queries. Rest of the section of this chapter will describe how to connect SQL IDE (Integrated Development Environment) to Ignite cache and executes some SQL queries to play with the data. SQL IDE or SQL editor can simplify the development process and allow you to get productive much quicker. Most database vendors have their own front-en

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

Load balancing and fail over with scheduler

Every programmer at least develop one Scheduler or Job in their life time of programming. Nowadays writing or developing scheduler to get you job done is very simple, but when you are thinking about high availability or load balancing your scheduler or job it getting some tricky. Even more when you have a few instance of your scheduler but only one can be run at a time also need some tricks to done. A long time ago i used some data base table lock to achieved such a functionality as leader election. Around 2010 when Zookeeper comes into play, i always preferred to use Zookeeper to bring high availability and scalability. For using Zookeeper you have to need Zookeeper cluster with minimum 3 nodes and maintain the cluster. Our new customer denied to use such a open source product in their environment and i was definitely need to find something alternative. Definitely Quartz was the next choose. Quartz makes developing scheduler easy and simple. Quartz clustering feature brings the HA and