<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><div>thanks ,&nbsp;Both are possible ways for the issue though they are a little complicated.</div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">发件人:</span></b> Michael Anstis &lt;michael.anstis@gmail.com&gt;<br><b><span style="font-weight: bold;">收件人:</span></b> Rules Users List &lt;rules-users@lists.jboss.org&gt;<br><b><span style="font-weight: bold;">发送日期:</span></b> 2011/3/19 (周六) 12:25:48 上午<br><b><span style="font-weight: bold;">主   题:</span></b> Re: [rules-users] how to ensure that one rule only is executed once?<br></font><br>You'd need to make sure
 you inform the engine that Order's price has changed:-<br><br>when<br>&nbsp;&nbsp;&nbsp; ...<br>then<br>&nbsp;&nbsp;&nbsp; modify( $o ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPrice( $o.getPrice() - 20);<br>&nbsp;&nbsp;&nbsp; }<br><br>You could also consider using agenda-groups or lock-on-active to provide your behaviour.<br>
<br><b>agenda-groups<br></b><br> rule "rule 1"<br>//implied default agenda-group of MAIN<br>when<br>&nbsp;&nbsp;&nbsp; $o : Order (amount&gt;100 &amp;&amp; &lt;200);<br>then<br>&nbsp;&nbsp;&nbsp; modify( $o ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPrice( $o.getPrice() - 10);<br>
&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; drools.setFocus("next step in calculation");<br>end<br><br>rule "rule 2"<br>//implied default agenda-group of MAIN<br>
when<br>&nbsp;&nbsp;&nbsp; $o:Order (amount&gt;200);<br>
then<br>&nbsp;&nbsp;&nbsp; modify( $o ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPrice($o.getPrice() - 20);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; drools.setFocus("next step in calculation");<br>
end<br><br>rule "rule 3"<br>agenda-group "next step in calculation"<br>when<br>&nbsp;&nbsp;&nbsp; $o : Order(....)<br>then<br>&nbsp;&nbsp;&nbsp; ....<br>end<br><br><b>lock-on-active</b><br><br> rule "rule 1"<br>
//implied default agenda-group of MAIN<br>lock-on-active true<br>
when<br>
&nbsp;&nbsp;&nbsp; $o : Order (amount&gt;100 &amp;&amp; &lt;200);<br>
then<br>
&nbsp;&nbsp;&nbsp; modify( $o ) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPrice( $o.getPrice() - 10);<br>
&nbsp;&nbsp;&nbsp; }<br>
end<br>
<br>
rule "rule 2"<br>
//implied default agenda-group of MAIN<br>

lock-on-active true<br>

when<br>
&nbsp;&nbsp;&nbsp; $o:Order (amount&gt;200);<br>

then<br>
&nbsp;&nbsp;&nbsp; modify( $o ) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setPrice($o.getPrice() - 20);<br>
&nbsp;&nbsp;&nbsp; }<br>
end<br>
<br>
rule "rule 3"<br>
agenda-group "next step in calculation"<br>
when<br>
&nbsp;&nbsp;&nbsp; $o : Order(....)<br>
then<br>
&nbsp;&nbsp;&nbsp; ....<br>
end<br>
<br><div class="gmail_quote">On 18 March 2011 16:08, Gabor Szokoli <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:szocske@gmail.com" target="_blank" href="mailto:szocske@gmail.com">szocske@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex;">
Hi,<br>
<br>
&gt;From what I know, it's generally better to make the rules idempotent:<br>
In your case introduce a discountedPrice field, leaving the original<br>
price alone.<br>
<br>
If you insist on making it run only once instead, you can introduce a<br>
field or fact class to mark an order "discounted", then all<br>
discounting rules know to ignore it. (This gets really complicated if<br>
the order amount ever changes and you do need to run the discounting<br>
rules again.)<br>
<br>
<br>
Gabor<br>
<br>
2011/3/18 yong zhao &lt;<a rel="nofollow" ymailto="mailto:cluncao@yahoo.com.cn" target="_blank" href="mailto:cluncao@yahoo.com.cn">cluncao@yahoo.com.cn</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi<br>
&gt; I just try to uses jboss rules in our projects. I met a question. for<br>
&gt; example<br>
&gt; package sample<br>
&gt; rule "rule 1"<br>
&gt; when<br>
&gt; &nbsp; $o:Order (amount&gt;100 and amount&lt;200);<br>
&gt; &nbsp;then<br>
&gt; $o.setPrice($o.getPrice()-10);<br>
&gt; end<br>
&gt; rule "rule 2"<br>
&gt; when<br>
&gt; &nbsp; $o:Order (amount&gt;200);<br>
&gt; &nbsp;then<br>
&gt; $o.setPrice($o.getPrice()-20);<br>
&gt; end<br>
&gt; if the fact , order's amount is 210. then the rule2 will be executed, then<br>
&gt; the rule1 will be fired . I want to stop the session once some rule is<br>
&gt; executed or how to control the rule flow.<br>
&gt; thanks in advance<br>
&gt; -Yong<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>
</div></div><div style="position:fixed"></div>


</div><br>






      &nbsp;</body></html>