[rules-users] Infinite loop when nesting rules

orchid maya.pollack at gmail.com
Mon Jan 11 08:20:33 EST 2010


Hi,

I have another question regarding rules nesting. I have the following Rule1
and Rule2 which check some property of Cheese type (I dont want to merge
them into one rule). The "then" part of these rules updates the list field
of class Cheese which holds the rules that were fired for a specific
instance. In Rule3 I want to check if Rule1 and Rule2 were fired:
 
rule "Rule1"
salience 100
no-loop true
  when
    $c:Chesse(type="Chedar")
  then
    modify ($c){addRule("Rule1")}
end

rule "Rule2"
salience 90
no-loop true
  when
    $c:Chesse(price < 100)
  then
    modify ($c){addRule("Rule2")}
end

rule "Rule3"
  when
    $c:Cheese(rules contains "Rule1" && rules contains "Rule2")
  then
    System.out.println("Rule3 was fired");
end

Rule1 and Rule2 cause infinite loop because of the 'modify' method. How can
I solve that issue?

Thank you very much in advance !!!
-- 
View this message in context: http://n3.nabble.com/Infinite-loop-when-nesting-rules-tp116764p116764.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list