Wednesday, June 1, 2016

Favourite Questions and Answers collected from ODM Developer Works Forums


How to load all rulesets in a ruleapp into cache at server startup?
Does ODM load all of the rulesets in a RuleApp into cache at server startup, or does it load the ruleset only when it is called?
If ODM does not load all of the rulesets in the RuleApp at startup by default, is there a way to do this. How to force ODM to load all of the rulesets of a RuleApp into ruleset cache at startup?
When a deployed ruleset is executed for the first time, the RES will load the ruleset from the database (if you are using database persistence), compile and cache the compiled code. This only happens once, and has no impact on performance after the first hit.
Note that the ruleset cache is not shared between XU Connection Factories:
·         1 XU Resource Adapter => multiple XU Connection Factories
·         1 XU Connection Factory=> 1 Rulesets cache (rulesets cache are NOT shared between XU Connection Factories)
·         1 Ruleset => multiple engines (IlrContext), Ruleset instances are shared between XU connection of the same XU Connection Factory but NOT between XU Connection Factories
·         1 XU Connection => 1 engine (IlrContext).
You can set up a web application that warms up rulesets by calling IlrManagementSession.loadUptodateRuleset() and another Java EE component or application that calls rulesets for execution. See this sample and also this discussion.
Additionally, you can customize the ruleset cache by writing your own implementation class (that implements interfaceilog.rules.res.xu.ruleset.IlrRulesetCache) and then modifying the deployment descriptor of the execution unit (XU) accordingly, see documentation.

Is there any API or code base to create Business Rule Report from DC remotely?

Hi All,
Is there any ODM API available to create business rule report remotely from DC.
Thanks
Package ilog.rules.teamserver.model.reporting defines the API related to reporting in Decision Center. There is sample code for class IlrReportEngine.

deploy ruleapp using REST API and curl

When I try to deploy a ruleapp using the ODM Rule Execution Server REST API and curl, the deployment fails with the following output:
1.   $ curl -i --header "accept: application/xml"  --header "Content-type: application/octet-stream" -X POST -d "/mnt/nas1/tmp/myruleap.jar" http://resAdmin:resAdmin@192.168.0.119:9085/res/apiauth/v1/ruleapps
2.   HTTP/1.1 202 Accepted
3.   X-Powered-By: Servlet/3.0
4.   Content-Type: text/xml; charset=UTF-8
5.   Content-Language: en-US
6.   Transfer-Encoding: chunked
7.   Date: Mon, 20 Apr 2015 21:05:39 GMT
8.   
9.   xml version="1.0" encoding="UTF-8" standalone="yes"?>
10.  
11.      The RuleApp archive is not valid.</message>
12.      false</succeeded>
13.  </result>
14.  
15.  
How to deploy a ruleapp using curl?
Make sure that you use the command line argument --data-binary ( instead of --data or -d ) and that the path to the ruleapp file is prefixed with a character @, as in:
1.   curl -i --header "accept: application/xml"  --header "Content-type: application/octet-stream" -X POST --data-binary @/mnt/nas1/tmp/myruleapp.jar http://resAdmin:resAdmin@192.168.0.119:9085/res/apiauth/ruleapps
2.   
When --data-binary is not used, a possible error message would be:
1.   java.io.EOFException
2.       at java.util.zip.ZipInputStream.readFully(ZipInputStream.java:426)
3.       at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:295)
4.       at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121)
5.       at java.util.jar.JarInputStream.<init>(JarInputStream.java:83)
6.       at java.util.jar.JarInputStream.<init>(JarInputStream.java:62)
7.       at ilog.rules.res.console.util.IlrManagementActions.deployRuleAppArchive(IlrManagementActions.java:160)
8.   ...
9.   
Like ·    2   Comment   Reward user   Share

When should dwAnswers "reward user" be used?

I noticed a new feature in dwAnswers - reward user. It is not explained in FAQ, but it seems I can give some of my own reputation points to the author of an answer. I wonder what is the use case for this feature? Why not simply "like" or accept the answer to show appreciation?
Hi Miriam, I asked a similar question a while ago, so you might want to check it out:
It seems that this new feature is meant to honor an exceptionally good or valuable post by transferring reputation points from your own account to the post author. It is true that accepting an answer or liking a post also results in the author earning a few reputation points but with 'Reward user', it is basically up to you how many points are awarded - at the expense of your own reputation.
I guess the feature will remain a controversial issue, especially since it shows quite some potential for misuse but just keep in mind: if you don't like it, you don't have to use it... ;-)

invoking IBM rule periodically

I have a requirement where I need to invoke a rule periodically lets say every 2 min. Is there such inbuilt timer functionality available in IBM ODM?
Darren answer applies to ODM Insight.
If you are using ODM Decision Rules Server, you must call the rule from any client and trigger the execution of this rule with any scheduler like cron.
Thanks Darren and odmgd for the answer. Its surprising that ODM insight supports this functionality whereas IBM Decision server does not. I wonder if IBM has any plans to add this functionality to IBM decision server.
Like ·    1   Comment   Reward user    Hide 1   Share
ODM Decision Server Standard provides stateless rules processing while ODM Decision Server Advanced provides stateful rules processing. In standard, the rules can use time to make decisions but will not monitor as time passes. In advanced, the server manages the concept of "now", maintains a cache of business events and entities relevant, and can trigger execution of anything such as a rule, custom Java code, or scoring model.
The functionality you are asking for was delivered when ODM Advanced was introduced. Please provide more detail for the requirements if our answers are not making that clear.

Date time support in IBM ODM

Has anybody used time operations in IF condition of a rule. I am trying to to find out difference of time in mins between two datetime and would like to know if any datetime functions are provided by IBM ODM for such operations?
Thanks. Ashish
Another option is to use a third party library in the XOM such as Joda Time. You can create a XOM from the Joda Jar file that references only the needed classes. In the attached example link text, I created a virtual helper BOM. I use this virtual BOM to simplify the code needed to use the comparison in a rule.
Now there is a simple rule that looks like below. See the attached Zip file for an example that runs in ODM 8.8.
1.   if
2.       the minutes between 'the start time' and 'the stop time' is more than 10
3.   then
4.       set 'the message' to "Minutes is more than 10.";
5.   else 
6.       set 'the message' to "Minutes is less than 10.";
7.   
8.   

ODM supplies classes ilog.rules.brl.IlrdateUtil and ilog.rules.xml.types.IlrDate with utility methods to handle Date/Time related types. If you need additional datetime functions, you must implement them as "Helper" virtual functions. Typically, helper methods are contained in a special BOM entry from an empty XOM.

How to configure ODM DC permissions such that artifacts in a folder are only visible to specific groups or users?

We are using ODM 8.8.0.0. We are trying to configure permissions in Decision Center, such that each user/group can view only artifacts in a specific folder. For example, in loanvalidation-rules project you have 4 folders computation, eligibility, insurance and validation. I want to create 4 users (computation, eligibility, insurance and validation) and each user can view only 1 dedicated folder.
1.    Create users, groups and roles and define user/group membership and group/role assignments in DC database. This task can be performed by an rtsAdministrator in the Administration tab of Business Console. There is a lab which demonstrates how to do this. If you do not use LDAP, you can start with section 3.
2.    Enforce project security (rtsAdministrator in Configure tab of Enterprise Console)
3.    Associate the rules or folders with the user's group (rtsAdministrator in Enterprise Console, set the "Group" property of rules or folders). This is a one-time task. After enabling "create" of rule artifacts to "group", each new action rule (or DT) will have the group property set.
4.    Set these permissions for each group (eligibility, computation etc.). Folder permissions are not propagated or inherited, so you must set permissions on the "action rule" or "decision table" level. 
Note: It seems that in Operational Decision Center v8.8.0.0 the "view" permission does not work correctly with "group". This is resolved in fixpack 1.

dc-permissions.png (14.3 kB)

Can a decision operation call another decision operation?

If not, can they be composed in some other way?
Example: you change the interface of a decision operation to accept additional data, so the input copybook changes. But there may be many existing clients who don't need to supply the additional data, but they will have to be updated because the copybook has changed.
If a decision operation could call another, you could create v2 of the operation and change v1 to call v2 with the additional data fields set to empty.
Thanks, Graeme
Answer by Miriam.Kaestner 
For non-Cobol clients, you don't need a wrapper decision operation to handle optional attributes in the signature (input or input-output parameters):
·         You can set an initial value for the input and InputOutput parameter in the variable set used for decision operation signature.
·         or add different constructors in the Java XOM
·         or initialize the optional parameter in B2X (add some IRL code).


Support for JSON in IBM odm 8.8 decision service +REST JSON example

Are there any samples which showcases various capabilities of IBM ODM 8.8 by exposing rules as a service using REST and JSON? I would also like to understand what current limitation for using REST and JSON.
Since ODM v8.7, REST service supports the JSON format for ruleset execution through the HTTP protocol. Ruleset parameters of primitive Java™ types, arrays, and Java XOM classes can be serialized to JSON through a Jackson process. You can test it in RES console (Ruleset View > Retrieve HTDS description file > REST > TEST > JSON).
Hi a_totade,
Yes there is a sample using the REST API :
This sample shows how to use the Rule Execution Server REST API in Java, and then how to use the result from the response as JSON objects.
Like ·    1   Comment   Reward user    Hide 1   Share
Thanks! I have seen that link. It shows how to use REST to interact with RES. I want to expose my rule as a REST service using JSON so that consumer application can invoke it.
Regards, Ashish

RuleApp Packaging - Best Practices

I am working on a use case for which I need to write 4 rulesets should be packaged into a RuleApp. These rulesets are decision service projects with Decision Engine mode.
May I know the best practices to follow to package more than 1 ruleset in a RuleApp?
·         Rulesets are packaged as RuleApp for deployment and execution.
·         To deploy a decision service to Rule Execution Server, you use a deployment configuration, which defines a RuleApp that contains the rulesets to be deployed.
·         A deployment configuration references one or more decision operations which group rules into a ruleset.
·         Each RuleSet is the invocation unit when executing the rules.
·         Each RuleSet has its own Input/Output parameters, Rules, Ruleflows, Variables, Functions
·         A ruleset is the minimal executable resource, identified as: ////
Some factors that influence the packaging:
·         Are the rulesets typically deployed as a group, or can they change individually at different times?
·         If your rulesets are changed often, you might like to keep a manageable version tracking history.
·         Separate RuleApps for different development teams and business groups simplify governance and organizing permissions
·         Consider the time it takes to deploy the ruleapp.

When to use libraries jrules-res-execution.jar and jrules-res-session-java.jar


Our client code uses JAR file jrules-res-execution.jar to open the session. As part of upgrade to new ODM version, we replaced this JAR with the new version of the same jar. After the migration the application cannot open session with IBM ODM RES and during session creation in the runtime we get exception:
1.   ilog.rules.res.util.IlrRemoteException:
2.   com.ibm.rules.res.xu.spi.internal.XUResourceAdapter incompatible with
3.   com.ibm.rules.res.xu.spi.internal.XUResourceAdapter
4.   
5.   
However after replacing the JAR file jrules-res-execution.jar with the JAR file jrules-res-8.7.0.0-session-java.jar the exception disappeared and the application can open session with RES successfully. We need to confirm if jrules-res-8.7.0.0-session-java.jar is correct JAR or not. Because our current application is using jrules-res-execution.jar in production.
Accepted answer
Answer by Miriam.Kaestner 
Libraries jrules-res-execution.jar and jrules-res-session-java.jar are provided for different purposes:
·         /executionserver/lib/jrules-res-execution.jar file is the XU stand-alone deployable unit for Java SE. You must package this jar if you intend to run your application in a web container, such as Tomcat or Liberty. To execute a ruleset in Java SE, you create a Java SE factory, a rule session, and a request.
·         If you use only POJO factories, package the /executionserver/lib/jrules-res-session-java.jar in your WEB-INF/lib directory. You can repackage as you want, but the goal is to grant access to the classes inside your servlet or JavaServer Pages. If your rules are written on Java classes, package them in the WAR file.
https://developer.ibm.com/answers/questions/173651/using-business-action-language-bal-services-in-ibm/

Using Business Action Language (BAL) services in IBM Business Process Manager (BPM) products might result in an exception


When you create BAL services in the IBM Business Process Manager products to write business rules using the built-in JRules engine, you might get an exception that the pool is full and the service fails to execute.
When you run BAL services, the following exception is thrown:
SystemOut O 1/11/12 1:58 PM [SEVERE] 10200 - -.- - Default connection manager pool is full ilog.rules.res.xu.cmanager.impl.IlrLocalizedResourceAllocationException: Default connection manager pool is full, error code: XU.ERROR.10200 at ilog.rules.res.xu.cmanager.impl.IlrConnectionManager.allocateConnection(IlrConnectionManager.java:72) at ilog.rules.res.xu.cci.IlrXUConnectionFactory.getConnection(IlrXUConnectionFactory.java:101) at ilog.rules.res.xu.cci.IlrCCIClientFactory.createManagementClient(IlrCCIClientFactory.java:161) at ilog.rules.res.session.impl.IlrManagementSessionBase.getClient(IlrManagementSessionBase.java:166) ... ... Caused by: ilog.rules.res.xu.pool.IlrPoolException at ilog.rules.res.xu.cmanager.impl.IlrDefaultPool.waitNotFull(IlrDefaultPool.java:154) at ilog.rules.res.xu.cmanager.impl.IlrConnectionManager.allocateConnection(IlrConnectionManager.java:69) ... 61 more
Rule Execution Server is deployed in the Java™ SE mode in the IBM Business Process Manager products. In Java SE, the Execution Unit (XU) Java archive (JAR) file includes a Java EE Connector Architecture (JCA) container, which creates and pools connections to the XU. The XU contains a default pool implementation and the default implementation sets the maximum size to 10. However, this value might not be always sufficient.
To resolve this issue, complete the following steps:
    1. Locate the following file in your IBM Business Process Manager installation:
    2. \BPM_HOME\BPM\Lombardi\process-server\lib\procsrv_resources.jar\ra.xml
    1. Make a backup of the original procsrv_resources.jar file in case you need to restore it. You can use native jar or 7-zip, for example, to unpack and update this file inside the JAR file.
  • Locate the following lines of code in the ra.xml file:
     
    defaultConnectionManagerProperties
     
    java.lang.String
  • Add one more line to above XML code as shown in the following code:
     
    defaultConnectionManagerProperties
    java.lang.String
     
    pool.maxSize=50
  • Update the JAR file with your modified ra.xml file.
  • Restart the server.
====


Do you know if the APAR Fix takes the same approach as updating the ra.xml configuration file?
Does anyone know if there is a way to clear the Pool without installing the Fix or updating ra.xml?