A rule will fire once fore each combination of matching facts, and then, again and again and again, whenever one of those facts is changed.

In your case: once for reason #1 and once for reason #2.

-W

On 30 October 2011 20:30, elsdestickere <elsdestickere@yahoo.com> wrote:
Hi,

The Expert documentation says " a rule may fire once or several times", but
I don't understand why a rule sould fire several times if the objects state
does not change?

I have an example of a Customer object inserted in the Working Memory, with
2 rules that should fire, but the last rule fires twice.
Can someone explain?

rule "isAdult"
   when
       k : Customer( age(date)>=18, adult==false );
   then
       modify( k ) { setAdult(true)  };
       System.out.println( "Drools "+drools.getRule().getName()+": "+
k.getAdult() );
end
rule "WM"
   when
      k : Customer(  ) ;
   then
       System.out.println( "Drools "+drools.getRule().getName()+": "
+k.getName());
end

...
Customer bert = new Customer ();
bert.setName("Bert");
bert.setDate(30);
ksession.insert(bert);
ksession.fireAllRules();
...
Output:
Drools WM: Bert
Drools isAdult: true
Drools WM: Bert

Br,
Els Destickere

--
View this message in context: http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users