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...

Apache Ignite Baseline Topology by Examples

Ignite Baseline Topology or BLT represents a set of server nodes in the cluster that persists data on disk. Where, N1-2 and N5 server nodes are the member of the Ignite clusters with native persistence which enable data to persist on disk. N3-4 and N6 server nodes are the member of the Ignite cluster but not a part of the baseline topology. The nodes from the baseline topology are a regular server node, that store's data in memory and on the disk, and also participates in computing tasks. Ignite clusters can have different nodes that are not a part of the baseline topology such as: Server nodes that are not used Ignite native persistence to persist data on disk. Usually, they store data in memory or persists data to a 3rd party database or NoSQL. In the above equitation, node N3 or N4 might be one of them. Client nodes that are not stored shared data. To better understand the baseline topology concept, let’s start at the beginning and try to understand its goal and what ...

Benchmarking high performance java collection framework

I am an ultimate fan of java high performance framework or library. Java native collection framework always works with primitive wrapper class such as Integer, Float e.t.c. Boxing and unboxing of wrapper class to primitive data type always decrease the java execution performance. Most of us, always looking for such a library or framework to works with primitive data type in collections for increasing performance of Java application. Most of the time i uses javolution framework to get better performance, however, this holiday i have read about a few new java collections frameworks and decided to do some homework benchmarking to find out, how much they could better than Java native collection framework. I have examine two new java collection framework, one of them are fastutil and another one are HPPC. For benchmarking i have used java JMH with mode Throughput. For benchmarking i took similar collection for java ArrayList, HashSet and HasMap from two above described frameworks. Col...