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

No comments: