<div dir="ltr">Hi Michael,<div><br></div><div>Here I use global static variables to store the dynamic salience values. I tried with facts and the results are all the same. </div><div><br></div><div>Thanks.</div><div><br></div>
<div>Jinghai</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 4:22 PM, Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com" target="_blank">michael.anstis@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I could be wrong but I thought dynamic salience used facts in working memory and hence your RHS would need to signal changes to the salience variables. </p>

<p dir="ltr">Sent on the move</p>
<div class="gmail_quote"><div><div class="h5">On 14 Jun 2014 00:01,  &lt;<a href="mailto:raojinghai@gmail.com" target="_blank">raojinghai@gmail.com</a>&gt; wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<div dir="ltr">Hi Mario,<div><br></div><div>I figured out this is a problem with Event and dynamic salience. Suppose we have the following declarations and rules:<br><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">


declare Message<br>    @role(event)<br>end<br><br>rule &quot;rule1&quot;<br>salience RuleSalience.RULE1<br>when<br>    $m : Message()<br>then<br>    System.out.println(&quot;====================&gt; rule1&quot;);<br>    retract($m);<br>


    RuleSalience.RULE1 = RuleSalience.RULE2 - 1;<br>end    <br><br>rule &quot;rule2&quot;<br>salience RuleSalience.RULE2<br>when<br>    $m : Message()<br>then<br>    System.out.println(&quot;=====================&gt; rule2&quot;);<br>


    retract($m);<br>    RuleSalience.RULE2 = RuleSalience.RULE1 - 1;<br>end  <br><br></blockquote>I want when a Message is inserted, either rule1 or rule2 is fired. I also want two rules can fire alternatively. So when one rule is fired, its salience becomes lower. </div>


<div><br></div><div>The result is, if I don&#39;t declare Message as an Event, it works fine. Otherwise, only rule1 is fired. </div><div><br></div><div>The problem seems to be at org.drools.core.reteoo.LeftInputAdapterNode::doInsertSegmentMemory(). Because of stream mode, both rules are not inserted StagedLeftTuples. So rule1 and rule2 are not compared based on salience. Because rule1 has a smaller act#, it is always fired first. </div>


<div><br></div><div>The attached zip is a test case. If you want mvn clean test, it will fail. However, if you remove the following lines from Sample.drl, the test will succeed. </div><div><br></div><div>&quot;declare Message<br>


    @role(event)<br>end&quot;<br></div><div><br></div><div>Thanks.</div><div><br></div><div>Jinghai</div></div>
<br></div></div><div class="">_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></blockquote></div>
<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></div>