[rules-users] Rules selection logic

Bala bala.ganesh at accenture.com
Mon Nov 15 01:08:22 EST 2010


I am using 5.0.1 version.

  In my application i dont have the rules in DRL files. I keep the Rules as
binary object and add all the rules to knowledge base. 

Here is the code to add the binary rules.

        inputStream = new ByteArrayInputStream(binaryRules);
        ObjectInputStream ois = new ObjectInputStream(inputStream);
        kpkgs = (Collection<KnowledgePackage>) ois.readObject();
        kbase.addKnowledgePackages(kpkgs);
.****************

Simple way to reproduce.
*******************

1) Add have two drl files HelloWorld.drl and Hello.drl

Add  the below code in HelloWorldExample java

kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl",HelloWorldExample.class),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("Hello.drl",HelloWorldExample.class),
ResourceType.DRL);


2)
Add the below rule in HelloWorld.drl

package org.drools.examples
 rule "hi"
when
  eval(1==1)
then
  System.out.println("Hello1");
end

3) Add the below rule in Hello.drl

package org.drools.examples
 rule "hi"
when
  eval(1==1)
then
  System.out.println("Hello2");
end

4) when i execute the attached HelloWorldExample java, i am getting the
output of the rule of latest added drl to the kbuilder(i.e Hello2 of
Hello.drl).

5) when i change the rulename, both the rules are getting executed.

6) But with the same rulename, when i change the LHS to eval(1<3) in one
rule, only the 4th step is getting reproduced.
********************************
 am i doing anything wrong?

Thanks,
Bala



http://drools-java-rules-engine.46999.n3.nabble.com/file/n1902934/HelloWorldExample.java
HelloWorldExample.java 
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-selection-logic-tp1894132p1902934.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list