Simplify developying decision services in Ilog jrules

Ilog Jrules define decision service as a ordinary web service with management capabilities using JMX MBeans. Through protocol SOAP, it's easy to invoke business rules rather than any other protocol like rmi. More information about decision services should find here.
From the view of ilog jrules, there are two types of decision services:
1) Hosted transparent decision services
2) Monitored transparent decision services

All of them drives rule execution and enables users to access Rule Execution Server through a Web service, rather than accessing it directly.
Hosted transparent decision services: Using a hosted transparent decision service, Rule Execution Server automatically exposes any deployed rule set as web services, that uses an XML schema or a Java XOM with simple types. The decision service automatically generates Web Services Description Language (WSDL) file for each deployed ruleset archive and the decision service MBean is able to retrieve execution statistics. These rulesets can be exposed as a Web service without passing through code deployment.
The hosted transparent decision service supports all primitive java type automatically. To use hosted transparent decision service, you should deploy transparent decision service archive in the same server where installed RES.
Now installed business rules with simple data type in RES will automatically exposes as web services. You can access wsdl from the rule set view of the installed business rules.

Whenever user click the link to get wsdl, component transparent decision service automatically generate the web service and a new decision service will found in the navigator.
If rule set contains custom java data types, the xom of the rule set must append to the jrules-bres-ootbds-JBOSS40.ear->jrules-bres-ootbds-JBOSS40.war\WEB-INF\lib directory and redeploy.
Through WSDL it's simple to create java proxy class to test the decision service. Most of the time, i use Xml spy editor to test soap service quickly. XML spy editor has options to create soap request and send it to the server.
Monitored transparent decision services:
Unlike a hosted transparent decision service, a monitored transparent decision service manages rulesets that use an XML schema or any Java XOM with simple types. XML parameters are represented by a String in the WSDL file.
Using the Client Project for RuleApps wizard, you can create the following projects:
1) A monitored transparent decision service project from your RuleApp project. The code generator generates two projects: the decision (or Web) service project, and the client project, which can be used to test the code generated in the decision service project. After the ruleset has been executed by this client, the transparent decision service can be monitored by the Rule Execution Server Console. Note that client generated by wizard is not well generating most of all time, it's better to generate client from the wsdl manually.
2) A Web service project from your rule project. The code generator generates a client project that can be used to test the code generated in the Web service project. This project cannot be detected by the Rule Execution Server management model, so the Rule Execution Server Console does not monitor rulesets executed by the client provided, or any other client.
Monitored transparent decision services created by RuleApps wizard execute rule set archive locally. Actually they never invoke rule set deployed in RES. So there will no execution statistics for the rule set will found in RES.
Generated decision services implements JAX-WS and only support jboss and tomcat.

Another effective way to invoke business rules are creating a web service as client to call business rules through J2EE provider. Here web service is the mediator of the business rules and client, web service encapsulate all the boilerplate code to call business rules in RES.


Best practice for writing effective business rules on Ilog Jrules

Documentation which supplied with Ilog Jrules is very much helpfull to write business rules. However, to write better business rules on Ilog Jrules, we might follow some best practice, which will help us to write and manage our rules. In the current post i would like to share my experince with Ilog Jrules as a best practice guide:
1) Follow java naming conventions when creating java class which will converted to BOM. Best approach will be create class with all its functionality.
2) Use rule packages, because on ruleflow you can use rule packages to contol running business rules effectively. However by default all rules under one package will run, you can use dynamic rule selection to select and run any particular business rules.

3) Use ruleflow task to initialize any global variables, it's not good idea to auto generate variable for any bom.
4) Also it's very usefull to use task for rule packages to intialize bom which will prticipate in the current package.
5) In many cases it's very use full to use task of ruleflow to define metadata which will take part of all business rules over the project. It's may be load any extra data from database tables or from ftp. However task of ruleflow only support java 1.4.
6) Use custom java class with static methods over virtual methods. Becuase it's a huge trouble to manage whole BOM with virtual methods in any extrem projects. During update of BOM you could lost your all virtual methods.
7) In BAL, when working with collections, use clause to filter as much element of collections as possible.
set 'personAddress' to serviceUtils . getAddressesFV ( the id of paramPerson )
where each IDWAddress FV is not null
and ( the city of each IDWAddress FV is not null
and the city of each IDWAddress FV is not empty
and utils.upperCase(the city of each IDWAddress FV) contains cityLookedFor ) ;

8) To use collection properly in BAL, you must use Collection interface rather then any implemented class. In version 6.7.2 there are also some bugs related with collections. One of the bug as follows, when calling any xom method with two collection parameters, Jrules mixed the two collections elements on first collection.
9) Write java utility class with static methods to use in BAL, for example compare two collections, check empty collections, check null values. Utility methods help you to write better effective business rules.
10) Use category filter to filter your boms, when you have a lot of classes with similar methods.
11) When using decision tables or decision tree, use precondition to check variable or paramerters which will take part of that rules, because it's realy hard to debug decision tables and tree.
12) In case of similar business rules, i prefared to use tempate for creating rules. It not only help to create rules from the scrach but also you can define category filter effectively for different users.
13) Use documentation field of any business rules to document the rules. I found it very help full when explains ours analyst to create similar rules in team server.
14) Use maven or ant script to create or update IrlSessionBean with your custom java libraries to invoke business rules in execution server.
15) Use j2se client to test the business rules before deploy it in execution server.


What will be the future of Oracle SOA suite?

Already last year company oracle defined thier fusion middleware strategy. You can find the webcast from here. Now at the moment in fusion middleware we got products as BPM suite and BPA suite.
BPM suite consists former Aqualogic products for BPM. BPM suite contains following products:
* Oracle BPM
* Oracle BPEL Process Manager
* Oracle Business Activity Monitoring
* Oracle Business Rules
* Oracle WebCenter Suite
Now we have two BPEL process manager product in two different suite such as SOA suite and BPM suite. From the documentation of BPM suite, seems it's a good road map to create model business process -> xpdl -> BPEL process.
What we will do with our favorite SOA suite?

Complete installation of Ilog Jrules on Oracle application server

With Ilog Jrules default distribution, Jboss application sever is default. But customers might choose any application server to use Jrules. In these circumstances, customers should deploy all the necessary components manually. The task is not so straight forward because Jrules consists of a few independent web components. In the following i will describe briefly how to install Ilog Jrules in OAS

Jrules consists of following three main web components:
1) RES
We follow step by step to install and deploy all the components in the OAS.
1) Install RES:
1.1) First we should create data base user and schema in Oracle DB for component Res.
1.2) Run the script in sqlplus or any other oracle sql client to create new data base objects from the following place
1.3)Create a new oc4j instance in the OAS named Ilog_bres
1.4)Create new connection pool and data source for RES as follows:
<connection-pool name="bresdatasourcePool">
<connection-factory factory-class="oracle.jdbc.pool.OracleDataSource"

<managed-data-source name="bresdatasource"

1.5) Add new roles and users by web interfaces as follows
1.5.1) Add role named bres_admin, which will extends from oc4j-administrator and also selects Grant RMI Login и Grant Administration realms for the role.
1.5.2) Add new user named bres and grant him the role bres_admin
1.6) Install all the following components manually in the oc4j instance Ilog_bres:
All components will be found in the following directory <ILOG_HOME>\JRules672\executionserver\applicationservers\oracle10g
Installed RES should be found on following url:
2) Install Team server:
2.1) Create two data base schema and user in the oracle DB.
2.2) From default installation of team server in JBOSS, we could generate sql script to create schema objects.
2.3) Run the sql script to create new objects in the data base schema
2.4) Create a new oc4j instance named ilog_ts.
2.5) Increase perm size memory for the container through web interface or add it to opmn.xml file as follows:
perm memory size: 128М, max memory size: 1024М, initial memory size: 512М (it's my configuration - you should calculate your ability)
2.6) Create connections pools and data sources for the container ilog_ts as follows:
<connection-pool name="ilogDataSourcePool">
<connection-factory factory-class="oracle.jdbc.pool.OracleDataSource"

<managed-data-source name=" ilogDataSource"

<connection-pool name="serverextendedbrmPool">
<connection-factory factory-class="oracle.jdbc.pool.OracleDataSource"

<managed-data-source name="serverextendedbrm"

2.7) Add following roles and users:
Roles: rtsAdministrator extends from oc4j-administrator with realms Grant RMI Login , Grant Administration, rtsInstaller and rtsUser
Users: rtsAdmin, which assign all the above roles.
2.8) Deploy the following application into the container:
jrules-teamserver-OC4J10.ear, which will found in the following directory
3) Install RSM:
Actually for Scenario manager it's not necessary to create another oc4j container, it will be to install it with res.
3.1) Create one more db schema and user in the oracle database.
3.2) No need to run any script to create data base objects, during installation of the application by data source, rsm will create data base objects need for him.
3.2) Add one more connection pool and data source in the container ilog_bres as follows:
<connection-pool name="rsmdatasourcePool">
<connection-factory factory-class="oracle.jdbc.pool.OracleDataSource"

<managed-data-source name="rsmdatasource"
connection-pool-name=" rsmdatasourcePool"

3.3) Create one role named rsm_user and add a user named rsm. Assign the role to the user rsm.
3.4) Deploy the following application in the container:
jrules-rsm-OC4J1013.ear, which will be found in the following directory <ILOG_HOME>\JRules672\scenariomanager\applicationservers\oracle10g\jrules-rsm-OC4J1013.ear
it's all what you need to install Jrules in the OAS.
Now some additional note:
1) If any problems will occurs for library commons-logging during installation, it should be better to update it with newer version. You should have find the library in the following directory: webservices/lib.
2) Delete the library commons-cli.jar from the shared library.
3)*** Fix the rmi port for all the above defined containers,
3.1) Open the ORACLE_HOME/opmn/conf/opmn.xml file with vi editor or any text editor.
3.2) Locate the <port id="rmi" range="12401-12500"/> entry for the instances ilog_bres and ilog_ts.
3.2) Choose one of the ports for RMI within the range of 12401 and 12500.
For example:
<port id="rmi" range="12402"/>

Now rmi ports are fixed for the containers and during restart or startups of OAS rmi ports will never change.
4) JMX services will be accessible by following url:
5) For solving transaction manager time out problem by rmi protocol do as follows:
add more seconds in transaction-timeout option as like 100 in the transaction-manager.xml file for every container, default is 30 seconds.


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();

/* Jboss configuration
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);
//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) {
} catch(RemoteException e){
} catch(IlrRuleSessionException e){
} /*catch(NamingException e){
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:


Method for avoiding error ORABPEL-100010 in design time

Error ORABPEL-100010 occures in design time when user add any user defined xml schema in order to define any element. Seems this design time bug was not fixed since

A handy method was found recently to avoid the above error.

Step 1: Add the user defined xsd file in the following catalog to access it through application server %BPEL_HOME%/bpel/system/xmllib

step 2: import the xsd file in any wsdl file of the project as follows
<import namespace="" location="http://your_localhost:8888/orabpel/xmllib/XXXX.xsd"/>

step 3: add the following namespace in your *.bpel process file


Use command line tool to compile the project.

Configure Oracle Coherence as a second level(L2) cache

It's republish of my blog from another domain. The post was published at May 13 2008.
A few weeks before Oracle corporation bought company tangosol, which have a caching framework for enterprise application. Coherence might be used as a second level cache or as Cache store in any enterprise solution. How to use coherence as a Cache store would be found in the following URL:  . In the current blog we will configure a coherence L2 cache using Hibernate (Hibernate - a well known ORM framework).

First, download oracle Coherence from the following URL

Using Coherence as L2 cache we only need 3 libraries out of others: coherence.jar, coherence-hibernate.jar, tangosol.jar.

Install them in local maven2 repositories. Now we have to configure hibernate.cfg.xml which should be in application classPath as follows:

By default Coherence will use configuration from coherence-hibernate.jar/coherence-config.xml. We may override the configuration by providing a new configuration file relaid in classpath named coherence-cache-config.xml. A simple coherence-cache-config provide in the following:

If logging is enable for the application, we would see log messages as follows:
2008-05-12 10:56:19,079 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,079 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,079 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,266 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,266 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,266 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,282 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,282 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,282 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,282 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,282 INFO [org.hibernate.cfg.SettingsFactory] -
2008-05-12 10:56:19,329 INFO [org.hibernate.impl.SessionFactoryImpl] -
2008-05-12 10:56:19.547 Oracle Coherence 3.3.1/389 (thread=main, member=n/a): Loaded operational configuration from resource "jar:file:/C:/Documents%20and%20Settings/sahmed/.m2/repository/com/tangosol/coherence/coherence/1.0/coherence-1.0.jar!/tangosol-coherence.xml"
2008-05-12 10:56:19.547 Oracle Coherence 3.3.1/389 (thread=main, member=n/a): Loaded operational overrides from resource "jar:file:/C:/Documents%20and%20Settings/sahmed/.m2/repository/com/tangosol/coherence/coherence/1.0/coherence-1.0.jar!/tangosol-coherence-override-dev.xml"
2008-05-12 10:56:19.547 Oracle Coherence 3.3.1/389 (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified

Oracle Coherence Version 3.3.1/389
Grid Edition: Development mode
Copyright (c) 2000-2007 Oracle. All rights reserved.

2008-05-12 10:56:20.954 Oracle Coherence GE 3.3.1/389 (thread=Cluster, member=n/a): Service Cluster joined the cluster with senior service member n/a
2008-05-12 10:56:24.204 Oracle Coherence GE 3.3.1/389 (thread=Cluster, member=n/a): Created a new cluster with Member(Id=1, Timestamp=2008-05-12 10:56:20.625, Address=, MachineId=49122, Location=process:3396@s-ahmed, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) UID=0xAC180BE200000119DBEA6091BFE21F98
2008-05-12 10:56:24.250 Oracle Coherence GE 3.3.1/389 (thread=main, member=1): Loaded cache configuration from resource "jar:file:/C:/Documents%20and%20Settings/sahmed/.m2/repository/com/tangosol/coherence/hibernate/coherence-hibernate/1.0/coherence-hibernate-1.0.jar!/config/hibernate-cache-config.xml"
2008-05-12 10:56:24.532 Oracle Coherence GE 3.3.1/389 (thread=ReplicatedCache:HibernateReplicatedCache, member=1): Service HibernateReplicatedCache joined the cluster with senior service member 1
2008-05-12 10:56:25,000 INFO [org.hibernate.impl.SessionFactoryObjectFactory] -
2008-05-12 10:56:25,016 INFO [org.hibernate.cache.UpdateTimestampsCache] -
2008-05-12 10:56:25,016 INFO [org.hibernate.cache.StandardQueryCache] -
2008-05-12 10:56:25.157 Oracle Coherence GE 3.3.1/389 (thread=main, member=1): Loaded cache configuration from resource "file:/E:/WorkSpace/MyProjects/Coherence/coherence-test/target/classes/coherence-cache-config.xml"
entity cache items:SafeNamedCache: CacheHandler

A much more configurations detailed in the user guide.


My first glance to Oracle Service Bus and compare with it Oracle SOA suite ESB

Recently Oracle gave access to download their new product Oracle ESB (formally known Aqua Logic ESB). Last year one of my project was related with SOA suite ESB. However, there were a few bugs with it, but we completed our project successfully with satisfaction.
When the times came to use Oracle OSB, i wondered with his functionality, a lot of Nodes and Actions pleased me well. At first it seems to be on workspace of BPEL but it's only for using on ESB. All these nodes made easy of ESB development. See the design template at a glance

However i have also found a cons in OSB is that, it haven't contains any built in JCA compatible adapter to connect with another resource. Throw proxy service OSB can use any type of protocol include FTP, SMTP, TUX. OSB defines these type of services SOAP without WSDL and XML without WSDL service. Take a look at the built in adapters in SOA suite ESB.

However, OSB hasn't contain any adapter, through proxy service OSB can integrate with any kind of legacy system and resources.
It would be better to take a glance in the following overall architecture of the OSB:

Link for download OSB.
A good book to learn OSB out here The Definitive Guide to SOA: Oracle® Service Bus, Second Edition.


Using JPA with ilog Jrules project

Last couple of months i have worked with Ilog Jrules. These BRMS has lot of functionality to use business rules effectively in any project. Sometimes it's very usefull to get some additional meta data from database to execute business rules. In Ilog jrules documentation is not so useful to know how to use JPA, however in documentation you should found a few information with bunch of code. This post will explain how to use JPA in ilog jrules project and save a couple of hours for new comm er in BRMS.
At first in jrules we have to build XOM(Execution object model), which will execute all the business logic. After that we define BOM (Business object model) from XOM to write business logic's in project.
For using JPA we will make a class which will get all the CRUD operations and delegate every thing to the DAO layer.
Class diagram is as follows:

Here implemention of the IDAOService interface is a basic implemention of the DAO pattern and initialize session manager to manage all the CRUD operations. I guess explanation of the DAO pattern is redundant.
Now at these moment we can create BOM from the XOM and define only the JPAService. JPAService operations will be available for writting buseinss rules.
After creating BOM we have to initilize the JPAService class to use.
In Jrules there are two ways to do that.
1) In the class verbalization of JPAService in BOM we can select the check box named .

2) Most effective method and which i preffered is to initialize the JPAService class in the initial task of the rule flow as follows:
first we will create a global variable named serviceUtils of the type of JPAService, and then initilize the valiable in the initial action of the rule flow.

Now we are ready to use these variable in BAL, decesion Tree, decesion Table even in the IRL construction.
In following i put some frugment of BAL code,
set 'partners' to serviceUtils . getPartners ( the id of paramPerson )
where each IDWPerson recepients is not null
and (the person type sys name of each IDWPerson recepients is not empty and the person type sys name of each IDWPerson recepients contains "UL")
and ( the fact address of each IDWPerson recepients is not empty
and ( utils .upperCase(the fact address of each IDWPerson recepients) contains "Delhi"
or utils .upperCase(the fact address of each IDWPerson recepients) contains "Kanpur" ) ) ;
set 'partnersId' to serviceUtils . getPersonsId ( partners ) ;
buffer . isEmptyCollection ( partnersId ) is false
add partnersId to the frst collections of varBuffer ;
print "partners found" ;

Some additional information:
You must supply all the necessary libraries of JPA to J2eeruleSession.ear to invoke business rules remotly. Also must add all the libraries in the jrules-rsm-ssp.war file to use in scenario manager.
P.S. I assume all the information will help somebody to save couple of hours to develop business rules with JPA.


Configure POM to build maven project in continuum

If you are using SVN for version control with username password credential, it is not srtaigh forward to add new project with multiple modules. Server continuum couldnot save the user name and password defined on the add project forms. These bug only occured when using SVN as version control, with CVS these bugs not found yet. With minimum change on pom.xml of multiple module could resolve these problem. Just define username and password in the pom.xml for authentification. I define a pom.xml as follows to show the configuration.

Now continuum will add project sucessfully, even you could use following commands from your terminal:
mvn scm:update
mvn scm:validate
Following link show all avaliable scm commands:
maven scm commands
But these way we have also a cons here, everybody from your developer group of these project will know your username and password. Anyway, we could use single number of user credential to build project on the Continumm server.
Continuum project build notifier can be also configured by following fragment code.