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.<br><br>In your case: once for reason #1 and once for reason #2. <br><br>-W<br><br>
<div class="gmail_quote">On 30 October 2011 20:30, elsdestickere <span dir="ltr"><<a href="mailto:elsdestickere@yahoo.com">elsdestickere@yahoo.com</a>></span> wrote:<br><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>
<font color="#888888"><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>
</font></blockquote></div><br>