For repeated changes of a fact (the Score thing, in your case) a stateful session should be used. Then, the update of your Score fact would be<br><br>   modify( s ){<br>      setValue( s.getValue() + 4 )  // 4 or whatever <br>
   }<br><br>Repeated firing of the &quot;threshold&quot; rule is due to the Engine&#39;s reassessment of your Score fact after each increment, irrespective of its value field being below or above the threshold. Therefore, firing happens after each change above the limit.<br>
<br>You could reduce this to a single firing by adding another boolean field &quot;alerted&quot; which is set to true in the RHS of this rule and included in the rule&#39;s LHS:<br>when<br>   s : Score( value &gt; 40, alerted == false )<br>
then<br>   modify( s ){<br>       setAlerted( true )<br>   }<br><br>-W<br><br><br><div class="gmail_quote">On Sun, May 17, 2009 at 7:27 PM, David Boaz <span dir="ltr">&lt;<a href="mailto:davidb@dbmotion.com">davidb@dbmotion.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Dear all,<br>
<br>
First, let me inform that we are using stateless sessions in Drools 5 CR1.<br>
In my application I have to compute a score and if the score is above a<br>
threshold, an alert is created.  The score is accumulated from many small<br>
rules (actually, generated from excel using drools decision-tables).<br>
<br>
Initially, many input objects and a Score object initialized to zero are<br>
inserted. The form of my rules is:<br>
<br>
1       rule “accumulate #1”<br>
2               when<br>
3                       Input(....)<br>
4                       s:Score()<br>
5               then<br>
6                       s.add(4) // 4 is just an example<br>
7       end<br>
8<br>
9       rule “threshold”<br>
10              when<br>
11                      Score(value&gt;40)<br>
12              then<br>
13                      Alert.create(..)<br>
14      end<br>
<br>
1.The Score object was actually accumulated as expected. But for some<br>
reason, the “threshold” rule fired once when the score.value was still ==0.<br>
2.I tried to set the salience of the “threshold” rule to -1 (low priority).<br>
But it didn&#39;t affect the rule firing.<br>
3.I suspected that the engine was not informed that the score object was<br>
updated in the first rules. So, I added a call to drools.update(s) after<br>
line 6. That solved the issue and the “threshold” rule actually fired. But<br>
now, I noticed that several alerts were created because the score was set<br>
several times to a value&gt;40.<br>
4.To solve that new issue, I set again the salience of the threshold rule to<br>
-1. This time, only one alert was created.<br>
<br>
My concern is that I don&#39;t understand what happened. Can someone please<br>
explain?<br>
<br>
To my understanding, the situation described in my second bullet should<br>
work. Initially, all the inserted objects are checked in the RETE network<br>
and an agenda is created. The activation for the “threshold” rule is the<br>
last one. I don&#39;t see the reason how can the threshold rule fire before all<br>
the accumulate rules were fired.<br>
<br>
Thanks for the help, David<br>
--<br>
View this message in context: <a href="http://www.nabble.com/rule-with-low-Salience-is-fired-too-early-tp23585593p23585593.html" target="_blank">http://www.nabble.com/rule-with-low-Salience-is-fired-too-early-tp23585593p23585593.html</a><br>

Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
<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></div><br>