<p>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.</p>
<p>IIRC no-loop or lock-on-active can be uses to avoid this, but I'd suggest you double check the docs.</p>
<p>sent on the move</p>
<p>On 30 Oct 2011 19:31, "elsdestickere" <<a href="mailto:elsdestickere@yahoo.com">elsdestickere@yahoo.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
The Expert documentation says " a rule may fire once or several times", but<br>
I don't understand why a rule sould fire several times if the objects state<br>
does not change?<br>
<br>
I have an example of a Customer object inserted in the Working Memory, with<br>
2 rules that should fire, but the last rule fires twice.<br>
Can someone explain?<br>
<br>
rule "isAdult"<br>
when<br>
k : Customer( age(date)>=18, adult==false );<br>
then<br>
modify( k ) { setAdult(true) };<br>
System.out.println( "Drools "+drools.getRule().getName()+": "+<br>
k.getAdult() );<br>
end<br>
rule "WM"<br>
when<br>
k : Customer( ) ;<br>
then<br>
System.out.println( "Drools "+drools.getRule().getName()+": "<br>
+k.getName());<br>
end<br>
<br>
...<br>
Customer bert = new Customer ();<br>
bert.setName("Bert");<br>
bert.setDate(30);<br>
ksession.insert(bert);<br>
ksession.fireAllRules();<br>
...<br>
Output:<br>
Drools WM: Bert<br>
Drools isAdult: true<br>
Drools WM: Bert<br>
<br>
Br,<br>
Els Destickere<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.html" target="_blank">http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></p>