Sunday, April 27, 2014
sample for "calling ruleset using ejb ,i.e., "Calling a ruleset using an EJB factory and a stateful session"
The first step is to create a connection to the RES via EJB I signal as below:
Mapconexao = new HashMap();
IlrEJB3SessionFactory sessionFactory = new IlrEJB3SessionFactory();
String jndiName="ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote"; //default JNDI in WAS
sessionFactory.setStatelessRemoteJndiName(jndiName);
sessionFactory.setRemote(true);
IlrPath rulesetPath=null;
try{
rulesetPath = IlrPath.parsePath("/HelloWorldRuleApp/HelloWorld");
}catch (IlrFormatException e1){
e1.printStackTrace();
}
conexao.put("sessionFactory", sessionFactory);
conexao.put("jndiName", jndiName);
conexao.put("rulesetPath", rulesetPath);
Then you will connect to RES from EJB created and will query the ruleset. Remember that you will be working with an object. In the example below I use the object person.
IlrSessionResponse response=null;
IlrSessionRequest request = sessionFactory.createRequest();
request.setRulesetPath(rulesetPath);
Person person = new Person();
person.setName(name);
request.setInputParameter("person", person);
request.getTraceFilter().setInfoTotalRulesFired(true);
request.setTraceEnabled(true);
try{
IlrStatelessSession session = sessionFactory.createStatelessSession();
System.out.println("created session " + IlrJNDIConstants.STATELESS_SESSION_EJB3_NAME);
response = session.execute(request);
Tuesday, April 22, 2014
RuleApp and Ruleset naming conventions
RuleApp and Ruleset naming conventions
Question
What are the naming conventions for RuleApps and Rulesets?
Cause
RuleApp or Ruleset names can only contain letters, digits, or underscores.
The names can only start with a letter or an underscore.
Those conventions are enforced in Rule Studio, the Rule Team Server and Rule Execution Server consoles. In Rule Studio, any forbidden characters will be kept for the 'Display name' but removed for the 'Name' of the RuleApp/Ruleset which is used to build ruleset paths.
You can also validate RuleApp and Ruleset names through the API with :
until V6.7, the validateRuleAppName/validateRulesetName methods of ilog.rules.bres.model.IlrNameValidator.
starting in V7, the ilog.rules.res.model.IlrPath.parsePath static method.
In both cases an IlrFormatException will be thrown if a name is not valid.
===
Question
What are the naming conventions for rule artifacts?
Answer
As a rule author, you are allowed to use spaces within rule artifact names, as well as digits, but you are not allowed to use
spaces at the beginning and the end,
the following characters: ", ., :, *, /, <, >, ?, \, |..
Those conventions are enforced in both Rule Studio and Rule Team Server. In Rule Studio, creating a package with a name that contains one or more dots ('.') will generate a succession of imbricated folders.
The name you create is the Business Name. For the rule to become executable, this name must be translated into a Technical Name.
That translation uses JRules IRL code. IRL code is the runtime code that is automatically generated from rule project artifacts. IRL code follows the same syntax as the syntax used for Java identifiers. Therefore, any character that is not allowed in a Java identifier must be processed for the rule name to become valid.
The substitutions currently performed to generate a technical name are:
A space is replaced by an underscore character: _
$ is replaced by $$
_ is replaced by $_$
A leading digit is replaced by $$
For rule tasks, a "ruleflowName#" prefix is added to the rule name to prevent name conflicts when two rule tasks have the same names.
Note: To retrieve the rule business name from its technical name, use the method IlrNameUtil.getBusinessIdentifier(String identifier).
======
Rule project item naming conventions
Make sure that you use the Java naming conventions when you create a name for your rule project items. You can use spaces because they are processed into valid characters when you execute, but do not use spaces at the beginning of a name.
The name of a rule project item must not:
Be empty
Be longer than 255 characters
Start or end with white space characters
Contain the characters ",.,:,*,/,<,>,?,\, or |
Contain a character that has a ASCII or Unicode code below 0x1f, included
======
Rule project templates
You have a choice of templates for creating your rule project structure.
Standard rule project template
The standard rule project template creates an empty standard rule project. You can choose from the following options:
Rule Project References: To list the dependencies between your new rule project and other existing rule projects.
Rule Project Java XOM settings: To define the Java Execution Object Model (XOM). You can set the path on Java folders, JARs or projects.
Dynamic XOM settings: To define the dynamic XOM. You can set the path on XML schemas or dynamic XOM files.
Rule project model folders: To define the folders in the rule project to help you organize your rule project artifacts.
The standard rule project template populates the following folders:
Source folder (rules): Stores rule artifacts. It is good practice to organize your rule artifacts in the source folder with rule packages. Rule packages can contain other packages nested within them. Nested packages can contain all types of rule artifacts.
BOM folder (bom): Stores BOM entries. BOM entries define the structure of a BOM and its associated vocabulary and BOM to XOM mapping.
Query folder (queries): Stores queries.
Resource folder (resources): Stores any type of file that is not part of the rule model.
Template folder (templates): Stores action rule templates.
Predefined rule project template: Hello World project
This template creates a rule project containing the following items:
A single rule in a single package
A ruleflow
A BOM with two static methods
Rule Project with a BOM template
The Rule Project with a BOM template creates an empty rule project. You have the following options:
Rule Project XOM settings, to define the:
Java Execution Object Model (XOM). You can set the path on Java folders, JARs or projects.
Dynamic XOM. You can set the path on XML schemas or dynamic XOM files.
BOM entries and verbalization are automatically created for each XOM you specify.
Rule Project References, to list the dependencies between your new rule project and other existing rule projects.
Custom rule project templates
Custom rule project templates provide additional flexibility in creating rule projects. For information about custom rule project templates, refer to Creating a rule project template.
http://pic.dhe.ibm.com/infocenter/dmanager/v7r5/index.jsp?topic=%2Fcom.ibm.dserver.rulestudio%2FContent%2FBusiness_Rules%2F_pubskel%2FInfocenter_Primary%2Fps_DS_Rule_Designer621.html
=====
Creating a rule project template
The use of rule project templates can ensure greater consistency of rule project design and eliminate duplication of developer work.
You can create a rule project template based on all types of rule artifacts and any rule project structure, including a XOM project. You can create the template from multiple projects and project dependencies.
You create the template using a wizard. You can custom design the template by choosing the resources to be included in the rule project template. You can add template documentation to describe the template structure and use. The end result is an Eclipse plug-in for deployment.
To create a rule project template for Rule Designer:
On the File menu, click New > Other > Plug-in Project and then click Next.
In the Plug-in Project dialog, on the New Plug-in Project page, type in the name of the new rule project template.
Click Next.
Complete the Plug-in Content dialog and then click Next.
In the Templates dialog, select Plug-in that defines a new template for the Rule Project wizard and then click Next.
In the Resources to Include as Template Files dialog, on the New plug-in Project with Custom Templates page, select the resources to be included in the template and then click Next.
All the resources from the current project are listed for possible inclusion.
In the Custom Rule Project Template Settings dialog, complete the settings and then click Finish.
When you have created the new plug-in, you can test it. In response to the query, open the associated view. Use the Eclipse export wizard to export the plug-in to, for example, your Rule Designer Eclipse install directory. You can also deploy the plug-in directly, either in the Eclipse application directory or any directory that is an extension to the Eclipse application you are using. When you restart Eclipse, you can select the new rule project template.
==============
Engine excution modes Reteplus Sequential Fastpath information ILOG WODM JRules IBM Interview Questions
Engine execution modes
JRules supports the RetePlus, sequential, and Fastpath execution modes. The execution mode can impact which rules are fired and in which order.
In this section
RetePlus
The default execution mode is RetePlus. Use its optimization techniques to improve performance: reduction of the number of rules and conditions, computation of the rules to execute, and prioritization of the rule order.
Sequential
The sequential mode executes all the eligible rules for a given rule task in sequence, which provides specific performance advantages.
Fastpath
Fastpath is a sequential execution mode that also detects semantic relations between rule tests in the same way as RetePlus.
===
RetePlus
RetePlus, the JRules extension based on the Rete algorithm, is the default execution mode.
The RetePlus execution mode provides the means for the rule engine to minimize the number of rules and conditions that need to be evaluated, compute which rules should be executed, and identify in which order these rules should be fired. In RetePlus, the rule engine uses a working memory and an agenda for containing and manipulating application objects. The working memory contains references to the application objects, and the agenda lists and orders the rule instances that are eligible to be fired.
The following diagram shows the operation of the RetePlus algorithm.
Diagram
of the rule engine in RetePlus mode
The RetePlus algorithm operates as follows:
The rule engine matches the conditions of the rules in the ruleset against the objects in working memory. During the pattern matching process, RetePlus creates a network based on semantic relationships between rule condition tests.
For each match, a rule instance is created and put into the agenda. Then the agenda, based on some ordering principles, selects the rule instance that should be fired.
Firing the rule instance executes the rule action.
This action modifies the working memory by:
Adding a new object to the working memory
Removing an object from the working memory
Modifying the attributes of an existing object.
The process continues cyclically until there are no more rule instances left in the agenda.
In RetePlus, whenever the working memory is modified, the rule engine repeats the pattern matching process. It reassesses matches after each rule instance is fired and modifies the data. As a possible consequence, the list of rule instances in the agenda can change. Thus, RetePlus is incremental and data-driven. These execution characteristics give RetePlus superior performance on computation and correlation types of applications.
=====
Sequential
The sequential execution mode, as its name suggests, causes the rule engine to execute all the eligible rules for a given rule task in a consecutive manner.
The following diagram shows the operation of the sequential algorithm.
Diagram
of the rule engine in sequential mode
The sequential algorithm operates as follows:
The rule engine performs pattern matching on input ruleset parameters and on the conditions defined on the collections of objects in working memory.
For each match, a rule instance is created and immediately fired. When a rule instance is fired, it sets the value of an attribute or an output ruleset parameter.
Rules that are executed with the sequential algorithm are stateless. The sequential algorithm operates rather like an execution stack where pattern–matching rule instances are executed once with no re-evaluation of the rules. In rules that are executed in sequential mode, you cannot use existence conditions, such as there is at least one, or the number of, in relation to objects in the working memory. However, you can make such conditions refer to a collection of an object in the working memory.
Because of its systematic nature, the sequential execution mode performs particularly well on validation and compliance types of applications.
Rules can be processed sequentially using rule tasks within a ruleflow (see What is a ruleflow). For the very few cases where the performance of the ruleflow is paramount and the implementation is subject to large memory usage, you can use the provided task-runner API to make a rule task bypass the ruleflow (see Executing a rule task directly).
Sequential processing is specified in the algorithm property of the rule task. You can select it explicitly in Rule Studio. See Choosing an execution mode.
=====
Fastpath
The Fastpath execution mode improves the sequential compilation and execution of a rule project. Fastpath is a sequential mode of execution that also detects semantic relations between rule tests during the pattern matching process, like RetePlus.
The following diagram shows the operation of the Fastpath algorithm:
Diagram
of the rule engine in Fastpath mode
The Fastpath algorithm operates as follows:
The rule engine uses a working memory that references application objects or ruleset parameters. Fastpath performs the pattern matching process, as in RetePlus, by creating a tree based on semantic relations between rule condition tests.
For each match, a rule instance is created and immediately fired. When a rule instance is fired, it modifies objects in working memory, but these modifications are not taken into account and the rule engine does not repeat the pattern matching process. The action of the fired rule also sets an output ruleset parameter.
Fastpath combines features of the RetePlus mode for pattern matching and features of the sequential mode for rule firing. In this sense, it compares well for correlation types of applications as well as for validation and compliance applications.
Like the sequential mode, the Fastpath mode is a stateless mode. As such, it is dedicated to matching objects against a very large number of rules that individually perform simple discriminations or light join tests. It is best for very large number of rules to be fired in sequence directly without any agenda support. In addition to its advantages as a variant of the sequential mode, the Fastpath execution mode is designed to further optimize the execution of the compliance and validation rules, which constitute a substantial part of business rules.
======
Monday, April 21, 2014
Is there a way to loop a YouTube video to play repeatedly?
That feature may not be available.. although you can download them and autoplay or repeat or replay them in windows media player.
this will help you... Use 'zillatube'.
It is very easy to download and convert to mpg/mp3 format that is compatible for your windows media player.
It is the easiest way (and also the fastest).
It works very well.....just google search for 'zillatube'
====
go to http://www.youtubeslow.com, it has the repeat, loop, slow motion features already in, without you needing to download anything, it simply works. For example, if you wanna watch a guy fall on his head on repeat, just follow the link -> http://www.youtubeslow.com/watch?v=dT_fkwX4fRM&sti=618.384&eti=621.104&fq=70&fq2=5
======
Saturday, April 19, 2014
WODM 8.5 ILOG JRules Interview Training Questions Certification
difference between RetePlus and Sequential execution mode in ilog jrules
I have come across different execution modes when I used a ruleflow in ilog jrules , reteplus algorithm , sequential mode execution etc. Whats the difference between those. Please dont ask me to refer IBM docs. I already did. some other plain language explanation is appreciated.
RetePlus, an extension based on the Rete algorithm, is the default execution mode. Its optimization techniques are used to improve performance: reduction of the number of rules and conditions, computation of the rules to execute, and prioritization of the rule order.
In RetePlus mode, the rule engine minimizes the number of rules and conditions to be evaluated, computes which rules must be executed, and identifies in which order these rules must be executed.
In RetePlus, the rule engine uses a working memory and an agenda for storing and manipulating application objects. The working memory contains references to the application objects. The agenda lists and orders the rule instances that are eligible to be executed.
The sequential mode executes all the eligible rules for a given rule task in sequence, which provides specific performance advantages.
A "very" simple explanation:
RetePlus in simple terms allows objects in working memory (WM) to be inserted/deleted/updated, then evaluated and matched with the conditions on the rules. Any rules that do match get put into an agenda and then fired. If those rules change data in working memory, this could potentially fire more rules whose conditions match the changed objects. The cycle continues until there are no more rules that match the objects in WM.
Sequential pretty much runs through the rules in the specified order, firing off rules whose conditions match the objects then exits. Any changes to data will not be re-evaluated and will not fire further rules.
There is also Fastpath, that sits in between. It uses the condition matching capability of RetePlus (for performance reasons), but does not re-evaluate changed data (so is not cyclical).
======
ILOG dynamic ruleset
public void executeRules(IlrRule[] rules){
IlrRuleset rulesetNew = new IlrRuleset();
IlrContext ctxt = new IlrContext(rulesetNew);
IlrTask task = ruleset.getTask("ExecFlow#exe");
IlrRuleTaskRunner runner = ctxt.getRuleTaskRunner(task);
runner.setActiveRules(rules);
int fired = 0;
runner.runInitialActions();
fired += runner.runBody();
runner.runFinalActions();
}
How we can create a dynamic ruleset from group of rules? this group is a dynamic. I am using IBM ODM 8.0.1
3 Answers
All Java implementation are disappeared, we used irl language, this is the solution :
We defined the scope and we select the rules dynamically
scope= {exe.R05,exe.R04,exe.R03}
body = dynamicselect() {
return selectedFunction(context.getRuleset().allRules);
}
body = dynamicselect() {
return selectedFunction(context.getRuleset().allRules);
}
Is sufficient to custom the rules which you like to executed.
Just be careful with dynamic selects. If you have a lot of rules, it can increase the execution time of the rule set significantly.
=========
Remove whitespaces, from input string type parameter value, using BAL in ILog Jrule
I have a rule which take a String type input parameter. Can I remove the whitespaces from the value this parameter holds using BAL.
If not what is the other option to do this. In this JRule there is a decision table where condition column is this parameter and then output is action column.
Say you define Rulset Paramter "Name" of type String for Rule IsDepartmentManager where output ruleset parameter is boolean.
Now in the decision table the values in Name column is say "John" and out for this is True. Otherwise False.
Now when this rule is invoked as web-service the input send is "John ". As the name contains white spaces and the decision table do the exact matching, the result return is False.
Solution
You can add an Initial Action in your Rule Task (that contains the Decision Table or the rule) in which you can execute theInputString.trim();
--Yes that's another approach, but as I said in my last paragraph in my answer, the best approach would be to cleanse and trim the data before passing it into the rules, so the rules (or rule flow tasks in your example), don't have to do anything with the data.
--Yes it is another aproach that i use to validate/correct the input parameters to avoid surprises at rules execution. – Akram GARGOURI
Can you post an example of the rule? It would be good to see why you need to trim the string in the first place.
But you could write a function to do this and expose it via the BOM. This can be done two ways. First, you could write a virtual function directly in the BOM that takes a string and trims it. The second option if you use Java XOM's is to write the function in Java and expose that via the BOM.
If your using the virtual function approach, then the code will be written using IRL, but this is essentially a cut down version of Java so it will have the String object methods needed to trim. For example:
return theString.trim();
To add a BOM function, do the following steps:
Right click the "bom" folder in the Eclipse rules project.
Select "BOM Entry" from the menu.
Select the "Create an empty BOM entry" option and then click "Finish".
Double click the new BOM entry to bring up the BOM editor view, and then click "New Class".
Enter the class name and then click "Finish".
Double click the new BOM class from the list, then under the "Members" section, click the "New" button.
In the new member dialog box, select the "Method" option, enter a name for the method, and add a parameter as a String type. Finally set the return type as a String type. then click the "Finish" button.
Then double click the new method under the "Members" section, and select the "Static" and "Final" options, and create a default verbalisation under the "Member Verbalisation" section.
Under the "BOM to XOM Mapping" section, enter the code I put in my original answer above, changing the parameter name to match what you have used.
Go back to the class level BOM editor and set the "Execution name" to the value "void" in the "BOM to XOM mapping" section. This is needed because the BOM class is not linked to a Java class (XOM).
Once you have done this, you should then be able to see the new method in the BAL editor for the rule.
However, what I would say is that you should try and trim and prepare the data before passing it into the rule set. Ideally you want a little custom functions in the rule set as possible to keep the rules as clean as possible.
I had added the example. Can you please suggest a solution now. We don't have BOM in our Jrule
I wish I could have found such a clear procedure in the IBM documentation. Many thanks!
================
How to determine whether extensions have been made to JRules that won't be automatically converted to ODM?
I am facing an upgrade of the JRules 7.112 portion of our application to ODM 8.5. Unfortunately, the people who did the JRules work are no longer around, and we lack much in-house expertise.
http://www-01.ibm.com/support/docview.wss?uid=swg21589725#modelExtensions
Migrating from JRules to ODM lists the steps that need to done to upgrade. Apparently, there are several scripts to assist in upgrading to ODM, but several things must be done manually. Migrating rule model extensions and extension data are among these. Is it sufficient to search for *.brmx files and *.brdx files to determine whether these extensions were done? Other words of wisdom (e.g., regarding incompatibilities, "gotchas") regarding the migration process are also welcome.
Solutions
If you go to where you have installed ODM 8.5, you will find a directory called "teamserver/bin".
In here you will then find two files, "defaultExtension.brdx" and "defaultExtension.brmx".
Make a copy of these files, then open them up and compare the contents with your JRules 7.1 versions to see if there are any differences.
Once you have got these upto date, then you can upload them to your ODM 8.5 Decision Server database by going through the Installation Wizard (Configure->Installation Settings Wizard) when you set up your new ODM 8.5 Decision Centre database.
You need to do all this before you migrate the old 7.1 database to 8.5 as it expects the new target ODM 8.5 database to be there when you run the migration Ant task.
If you need any more help on this, just let me know.
============
WebSphere Help, Tips & Tricks
Help, Tips & Tricks related to Java, Websphere Application, Portal Server and More.
============
(ILOG) IBM ODM 8.5 Logging a name of the rule in execution time
I want to create a log such as System.out.println("RuleName : "+ruleName); in IBM ODM rule engine.
So these are what i did;
1- Create BOM virtual methods which are static and get parameter of instance which is the object of ilog.rules.engine.IlrRuleInstance.
instance ilog.rules.engine.IlrRuleInstance
2- Create BOM to XOM mapping by the following
System.out.println("Log icinde");
String ruleName = "";
if (instance != null )
ruleName = instance.getRuleName();
else
System.out.println("instance null!");
if (ruleName != null) {
System.out.println("RuleName: "+ ruleName);
}
return;
3- Call it in rule flow as an initial or final action.
utility.logla(ruleInstance);
But when i execute the flow my log doesnt work instance is null and ruleName also is null;
How should i configure and set logging feature by using bom. Could you give me an example of it?
Thanks.
So you could use Decision Warehouse that is part of the execution server to trace each execution. This can include which rules have been fired during the execution, but depends on what filters you apply.
Here is the documentation on DW and how to set it up: http://pic.dhe.ibm.com/infocenter/dmanager/v8r5/topic/com.ibm.wodm.dserver.rules.res.managing/topics/con_res_dw_overview.html
It is because you are calling the getRuleName() outside of the context of a rule instance within your rule flow, from what I can see from your description.
If you had a BOM method called from within the action of a rule, you could then call IlrRuleInstance.getRuleName() and it would return the name of the rule (I have done such a thing myself before).
What are you trying to achieve with this logging?
Thank you for your response but as you told here I can't call that method IlrRuleInstance.getRuleName() in BOM to XOM mapping field. As I see the instance only work on action rules; whatif i want to call it in rule flow in BAL area? Or is there anyway to call it in BAL area in rule flow. The point i want to reach in here call it in BAL area in rule flow by using BOM. And I want to see which rules are activated which are not in run time, that is what i want to achive
=====================
How to test ILOG JRules Ruleset without using DVS?
I'm trying to use JRules BRMS 7.1 for a project. And I found out that DVS has some limitation in testing Ruleset.
It is that it cannot test the content in collections of complex type in Excel scenario file templates.
But I understand it is normal as that kind of content is too complex for an Excel table format.
So anyone has any idea what is the best way to test a ruleset that need tons of test cases with lots of complex type input without using DVS?
--
If developers are doing the testing, then use JUnit with an embedded rule engine. If non-technical users need to perform testing, it may be simplest to upgrade to WODM 7.5 which does not have this limitation. If that is not an option, then it is possible to use JRules 7.1 DVS, but it is somewhat complex and involves creating a separate wrapper rule project that takes the output collections as input and in its XOM, performs the comparison with the actual results.
Raj Rao is correct, you can use array as expected results (input is easy) but you will have to use hidden JRules API and it is painful anyway.
JUnit or 7.5 is the answer.
Unless you want to pay IBM to do it, even so they may say it is not possible because it is not detailled anywhere :(
Cheers
PS: BTW, arrays of complex types as input is easy for sure and well documented, I think.
If you have deployed your rules as a HTDS service to RES, then you could use SoapUI to test the HTDS web service.
SoapUI allows you to set up test cases that can be used to test different scenarios.
========================
Calling Ilog Jrule Rules Execution server from java client
I am trying to execute a rule in IBM Jrule Rules execution server , using a java client. I am having Websphere community Edition V2.1 server, I am able call and execute the rules using JSF deployed in the samae server.
I want to call and execute the rules using a java client. I didn't find any way to do this,
In EJB. we can call EJB from web as well as from java client , by setting Initial Context envionment property. Is there any way similar to this is there, to call Rule Execution server rules, using java client, web part is already working.
import ilog.rules.res.session.IlrPOJOSessionFactory;
import ilog.rules.res.session.IlrStatelessSession;
import ilog.rules.res.session.IlrSessionFactory;
import ilog.rules.res.session.IlrStatefulSession;
import ilog.rules.res.session.IlrSessionRequest;
import ilog.rules.res.session.IlrJ2SESessionFactory;
import ilog.rules.res.session.IlrSessionResponse;
import ilog.rules.res.model.IlrPath;
import ilog.rules.res.session.extension.IlrExtendedJ2SESessionFactory;
import miniloan.Borrower;
import miniloan.Loan;
public class POJOEx {
public static void main(String... arg) {
// create rule session factory
//IlrSessionFactory sessionFactory = new IlrPOJOSessionFactory();
//IlrExtendedJ2SESessionFactory sessionFactory = new IlrExtendedJ2SESessionFactory();
// j2se factory
IlrSessionFactory sessionFactory = new IlrJ2SESessionFactory();
try {
// use stateless session for invocation
IlrStatelessSession statelessSession = sessionFactory.createStatelessSession();
//input parameter
Borrower borrower = new miniloan.Borrower("Joe", 600,
80000);
// in out parameter
Loan loan = new miniloan.Loan(500000, 240, 0.05);
IlrSessionRequest request = sessionFactory.createRequest();
//rule path
request.setRulesetPath(IlrPath.parsePath("/miniloanruleapp/2.0/miniloanrules/1.0"));
request.setUserDat("miniloanruleapp.MiniloanrulesclientRunnerImpl.executeminiloanrules");
request.setInputParameter("borrower", borrower);
request.setInputParameter("loan", loan);
//executing
IlrSessionResponse response = statelessSession.execute(request);
System.out.println("userdata = " + response.getOutputParameters().get("loan"));
System.out.println("outputString = " + (String) response.getUserData());
System.out.println("executionId = " + response.getExecutionId());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I am getting below error.
ilog.rules.res.xu.ruleset.impl.archive.IlrRulesetArchiveInformationNotFoundException: Cannot get the information about the ruleset /miniloanruleapp/2.0/miniloanrules/1.0
can anybody suggest where to specify Rules execution server url, username and password. like we specify InitialContext values in EJB.
================
Thursday, April 17, 2014
Questions ILOG JRules Interview IBM WODM Questions
Issue in running Debug mode in Rules Studio
I wrote a technical rule and would like to test this rule in debug mode. I am using JUnit test case for unit testing. i have deployed the ruleset in JUnit test project. I have set break points in technical rule. but while running in debug mode, the control is not stopping at the break points. I checked the "enable debug" option in archive.xml of the RuleApp project.
Please let me know what are the things i need to take care for testing a ruleset in debug mode.
Thanks in Advance.
Hari
==
Ans
you can run the rules in debug mode yes but you cannot have break points in the conditions only in actions.
Before using JUnit make sure you can run the ruleset in debug mode using a simple java project for rules.
A workaround to test the conditions is to create some print (log/sysout) functions returning true and just print the condition, one by one.
Hope ti helps
===
Calling Ilog Jrule Rules Execution server from java client
I am trying to execute a rule in IBM Jrule Rules execution server , using a java client. I am having Websphere community Edition V2.1 server, I am able call and execute the rules using JSF deployed in the samae server.
I want to call and execute the rules using a java client. I didn't find any way to do this,
In EJB. we can call EJB from web as well as from java client , by setting Initial Context envionment property. Is there any way similar to this is there, to call Rule Execution server rules, using java client, web part is already working.
import ilog.rules.res.session.IlrPOJOSessionFactory;
import ilog.rules.res.session.IlrStatelessSession;
import ilog.rules.res.session.IlrSessionFactory;
import ilog.rules.res.session.IlrStatefulSession;
import ilog.rules.res.session.IlrSessionRequest;
import ilog.rules.res.session.IlrJ2SESessionFactory;
import ilog.rules.res.session.IlrSessionResponse;
import ilog.rules.res.model.IlrPath;
import ilog.rules.res.session.extension.IlrExtendedJ2SESessionFactory;
import miniloan.Borrower;
import miniloan.Loan;
public class POJOEx {
public static void main(String... arg) {
// create rule session factory
//IlrSessionFactory sessionFactory = new IlrPOJOSessionFactory();
//IlrExtendedJ2SESessionFactory sessionFactory = new IlrExtendedJ2SESessionFactory();
// j2se factory
IlrSessionFactory sessionFactory = new IlrJ2SESessionFactory();
try {
// use stateless session for invocation
IlrStatelessSession statelessSession = sessionFactory.createStatelessSession();
//input parameter
Borrower borrower = new miniloan.Borrower("Joe", 600,
80000);
// in out parameter
Loan loan = new miniloan.Loan(500000, 240, 0.05);
IlrSessionRequest request = sessionFactory.createRequest();
//rule path
request.setRulesetPath(IlrPath.parsePath("/miniloanruleapp/2.0/miniloanrules/1.0"));
request.setUserDat("miniloanruleapp.MiniloanrulesclientRunnerImpl.executeminiloanrules");
request.setInputParameter("borrower", borrower);
request.setInputParameter("loan", loan);
//executing
IlrSessionResponse response = statelessSession.execute(request);
System.out.println("userdata = " + response.getOutputParameters().get("loan"));
System.out.println("outputString = " + (String) response.getUserData());
System.out.println("executionId = " + response.getExecutionId());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I am getting below error.
ilog.rules.res.xu.ruleset.impl.archive.IlrRulesetArchiveInformationNotFoundException: Cannot get the information about the ruleset /miniloanruleapp/2.0/miniloanrules/1.0
can anybody suggest where to specify Rules execution server url, username and password. like we specify InitialContext values in EJB.
===
Ans
Let me clarify what is RES because it seems there is a misunderstanding here, it may be me.
RES is used in Ilog terminology to describe multiple things:
- The web interface that allows you to manage your ruleapp.
- The actual application that you deploy on your WebSphere CE (or else) in order to execute the rules.
- The .jar files that allows you to execute the ruleapp locally.
You, AFAIK, cannot connect RES using a local JAVA application.
What you have coded is calling the rule engine contained in the RES*.jar files in order to execute your ruleapp locally.
There is no way you can use your JAVA application like you are using your EJB application.
You have to use a webservice or else which is feasible if you put the ruleapp name as a parameter of the web service for instance.
You are using miniloan so you probably know the example using the web interface where you can tell which version of the ruleset to use.
It will be the same if you want to programmatically manage your ruleapp deployed on RES (real application on your application server) you will need to use MDB. Nothing else.
It is disapointing, I know because I went through that, but there is no way I know (at least) to do that. This is not the behaviour you have to follow.
To make it work then put your ruleapp in the classpath (or root of your JAVA application in eclipse) and run it... Then you will execute your rules.
RES doesn't provide the same tools than RTS where you can access RTS from any JAVA application in order to manipulate your rule project.
You are 100% correct there is no way to tell the J2SE connection what is the server URL and hence no way to run your rules from the server.
Hope it helps.
========
How to check the length of a number in JRules
I am new to JRules coding.It may looks like a simple question. I would like to check the length of an number in JRules code. How to write the code for that. "the length of" phrase is expecting a string. I tried to use toString() to convert the number to String. But this is not working. Please give some idea.
========
Ans
You can do that in multiple different ways, quite like going to Rome. :)
1/ In your Java:
public static int getIntLength(final int myLovelyNumber) {
return (new Integer(myLovelyNumber)).toString().length();
}
Then, you add this lovely function to your BOM, and you verbalise it. Personally, I would create a separate library for such Helpers. An update will do the trick.
2/ In your BOM:
I will assume that you start from scratch
a/ Create a 'virtual' object in your BOM (personally, I would create a separate BOM for 'virtual' objects) and set the "execution name" (or something like that) to java.lang.object
b/ create a 'virtual' static method in the the 'virtual' object with one parameter: Integer returning a: int
c/ in the B2X of your new 'virtual' method add:
return param.toString().length();
d/ verbalise the method
Of course it is up to you to check for null value in Java or B2X.
These are the main ways of doing it. One could find more tricky ways, but for a beginner (or not), it is a good approach. Hope it helps.
PS: If you are happy with that then mark the answer as correct :)
===
What about negatives?, your solution will count the '-' as a significant value.
So part (1) should be...
public static int getIntLength(final int myLovelyNumber) {
return (Integer.valueOf(Math.abs(myLovelyNumber))).toString().length();
}
Also an 'int' can't be null. When you come to test it it'll be zero.
=====
Sunday, April 13, 2014
PERM - Labor Pending
1. Go to the following link to see if your A number shows up. Just enter the A number and Search. No need to select/enter any other information. If you get your case then congrats, you are lucky!
http://icert.doleta.gov/index.cfm?event=ehLCJRE...
2. If step 1 fails, go to the following link and click on the "Disclosure Data" tab. Download "PERM_FY2013_Q2.csv" and "PERM_Case_Data_FY2012.csv". Search for your A number in those files. If you find your case here, then check the status and act accordingly.
http://www.foreignlaborcert.doleta.gov/performa...
3. If step 2 fails, go to the following link and enter your employer's name in "Employer/Respondent" field and click "Go". If you find your case here, you have a tough luck as your case is in BALCA and it will take couple of years to clear. You can get your H1 extended without any problem but you have to be patient with your PERM process. So check for alternatives.
http://www.oalj.dol.gov/LIBINA.HTM
4. If step 3 fails, put a FOIA request with DOL as I did. Check the following link for more details.
http://www.trackitt.com/usa-discussion-forums/a...
I really really hope this will help you find more details than you currently have about your PERM labor... Good luck!
Subscribe to:
Posts (Atom)