Your first rule matches against the Customer, as does the second. The modify in the first rule causes both rules to re-evaluate. The first does not match but the second does.

IIRC no-loop or lock-on-active can be uses to avoid this, but I'd suggest you double check the docs.

sent on the move

On 30 Oct 2011 19:31, "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