Saturday

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/
Post a Comment