Hi All,

We have an issue in rule when migrating drools from 3.0 to 5.1 with "eval". To 
demo this error, I use the following code:

public class Info {
     public String getItem(int i) {
          return "item is " + i;
     }
}

 
In Drools 3.0, the following rule is fine:
rule "test eval"
    salience 1   
    when    
        info : Info()
        eval(into.getItem(0) != null)
   then
        System.out.println("test eval");
   end

But when using drools 5.1, it shows error "info can not be resolved".  I found 
a way to resolve this issue but don't know this is the best practice.

declare Item
     name : String
end

rule "insert item before eval"
    salience 0   
    when    
        info : Info()
   then
        Item item = new Item();
       item.setName(info.getItem(0));
       insert( item );
   end

rule "test eval"
    salience 1   
    when    
        item : Item(n : name)
        eval( n != null)
   then
        System.out.println("test eval");
   end

BTW, using "declare" in rule may cause memory leaking? We are seeing heap size 
growing after migrated to 5.1.

Thanks,

Liqun

 


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to