<div><br></div>   Nelson,<div><br></div><div>   How do you know one rule is firing, but not the other? Are you checking the audit log or using an agenda listener for that? Otherwise, if you think the rule is not firing because of your println in the consequence, you might be looking at the wrong &quot;symptom&quot;. There is a huge difference between writing an &quot;if&quot; like that in the consequence of a rule and writing a constraint like &quot;<span style="font-size: 10pt; font-family: &#39;Courier New&#39;; color: black; ">hitId ==<span> </span></span><span style="font-size: 10pt; font-family: &#39;Courier New&#39;; color: green; ">&quot;TIGR00549&quot;</span>&quot; in the condition of the rule, because the LHS of a rule is evaluated at &quot;insert&quot; time while the RHS is evaluated at the consequence fire time.</div>
<div><br></div><div>   So, from the information given, trying to imagine a scenario to explain why the syserr in the &quot;test&quot; rule shows up while the one in the first rule doesn&#39;t, here is a possible explanation:</div>
<div><br></div><div>* You insert the fact HmmHit, it activates both rules, but in a given time, before the &quot;Hmm Hit&quot; rule is fired, the value of hitId changes. In this case, the rule would still fire, but the &quot;if&quot; in the consequence is only evaluated after the change (during consequence fire time) and so evaluates to false, not printing the message.</div>
<div><br></div><div>   This is a pretty simple use case and we have several customers/users with thousands of rules and millions of facts in a single session and they are not facing anything like you described. So, while a bug is always a possible explanation, we need a way to reproduce your problem in order to give you a proper answer.</div>
<div><br></div><div>    Edson</div><div><br><div class="gmail_quote">2010/7/6 Axelrod, Nelson <span dir="ltr">&lt;<a href="mailto:naxelrod@jcvi.org">naxelrod@jcvi.org</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">









<div lang="EN-US" link="blue" vlink="purple">

<div>

<p class="MsoNormal">Hi,</p>

<p class="MsoNormal">We’re having some troubling problems that can be best
explained by the following two rules.  Based on the facts inserted into
the stateful knowledge session, we expected both rules to fire for an Hmm Hit
to TIGR00549, but only the “Test” rule fires.  Can anyone explain
how this could possibly occur?  There are no other rules added to the
knowledge base.  This was tested using Drools 5.0 on Windows XP and Linux
environments.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">rule</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot;HMM Hit&quot;</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">     <span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">when</span></b></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
hit : HmmHit( aboveTrustedHit ==<span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">true</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">)</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
p     : FeatureProperty( id == hit.hitId )</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
f     : Feature ( featureId == hit.queryId, properties<span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">not</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">contains</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">p )</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">     <span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">then</span></b></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           <span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">if</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">(hit.getHitId().equals(</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot;TIGR00549&quot;</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">)) {</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">                 
System.err.println(</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot;HMM Hit rule: &quot;</span><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">+ hit.getHitId() +<span> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot; &quot;</span><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">+ hit.getQueryId());</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
}</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">end</span></b></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"> </span></p>

<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">rule</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot;Test&quot;</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">     <span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">when</span></b></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
hit : HmmHit( aboveTrustedHit ==<span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">true</span></b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">, hitId ==<span> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot;TIGR00549&quot;</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">)</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
p     : FeatureProperty( id == hit.hitId )</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
f     : Feature ( featureId == hit.queryId, properties<span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">not</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">contains</span></b><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">p )</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">     <span> </span></span><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">then</span></b></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">           
System.err.println(</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot;Test rule: &quot;</span><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">+ hit.getHitId()
+<span> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:green">&quot; &quot;</span><span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">+ hit.getQueryId());</span></p>


<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#960000">end</span></b></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Notably, this error is dependent on the amount and/or order
of facts loaded into the knowledge session although we’re talking &lt;
20k facts total.  We have repeatedly found problems when running
system-level tests of our production rules that do not appear when we run our
unit tests, with issues such as this one that only show up after loading some
number of facts that are unrelated to the particular fact in question.   It’s
difficult to debug because we can see that fact handles that satisfy the when
conditions are in the knowledge session (i.e. the same facts that fulfill the
Test rule), but we do not have any obvious way to debug why the expected HMM
Hit rule does not fire.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Nelson</p>

<p class="MsoNormal"> </p>

</div>

</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>
<br></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>