Have you tried running what you have?<div><br></div><div>I&#39;d expect it to give the result you expect already (other than throwing an error because $lfna_SEI and $r_SE are not bound in the last rule and assuming chkRuleExpre is constant over time). Rules do not normally execute in any sequential order (unless you explicitly make them so). As the facts are inserted into WM they are matched against your rules and activations scheduled. When all facts are inserted into WM and you call fireAllRules the activations are played out and &quot;truth maintenance&quot; ensures the &quot;result&quot; of their firing is consistent with the facts in WM (either inserted by rules or the programmer). This is in essence &quot;how inference engines&quot; work.</div>
<div><br></div><div>After you&#39;ve called fireAllRules (and assuming you have a stateful session) you insert more ABC&#39;s then you&#39;d have to expect the last rule to be re-evaluated - following another call to fireAllRules. So in part when rule 3 ultimately gives the &quot;correct&quot; answer depends upon when you stop inserting ABC&#39;s.</div>
<div><div><br><div class="gmail_quote">On 17 September 2010 07:35, Ritesh <span dir="ltr">&lt;<a href="mailto:ritesh.khot@sungard.com">ritesh.khot@sungard.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi,<br>
<br>
I have 3 rules in my drl file and want the last one should get fired only<br>
after all the facts in rule1 and rule2 gets inserted in working memory.<br>
Please see below code for more understanding. Please suggest.<br>
<br>
Thanks<br>
<br>
declare DistinctAT<br>
     d_auditT : String<br>
end<br>
<br>
declare ActualSum<br>
     auditT : String<br>
     sumOfThree : BigDecimal<br>
end<br>
<br>
rule &quot;insert combined sum&quot;<br>
        dialect &#39;java&#39;<br>
when<br>
    ABC( $a:A, $b:B, $c:C )<br>
<br>
then<br>
        BigDecimal actSum = $c.multiply(0.13);<br>
        ActualSum $as = new ActualSum();<br>
        $as.setAuditT($a);<br>
        $as.setSumOfThree(actSum);<br>
        insert($as);<br>
        System.out.println(&quot;AT :&quot; + $movAuditT);<br>
end<br>
<br>
rule &quot;insert distinct AT&quot;<br>
<br>
        dialect &#39;java&#39;<br>
when<br>
    $a : ActualSum( $AT : auditT )<br>
        not DistinctAT( d_auditT == $AT )<br>
then<br>
        DistinctAT $disAT = new DistinctAT();<br>
        $disAT.setD_auditT($AT);<br>
        insert($disAT);<br>
        System.out.println(&quot;Done!&quot;);<br>
end<br>
<br>
rule &quot;Get Sum Group by AT&quot;<br>
<br>
        dialect &#39;java&#39;<br>
when<br>
<br>
DistinctAT( $dAT: d_auditT )<br>
<br>
$total : Double()<br>
from accumulate( ActualSum( auditT == $dAT, $actSum_Main : sumOfThree ),<br>
sum( $actSum_Main ) )<br>
<br>
eval(<br>
        chkRuleExpre( $total,$lfna_SEI,$r_SEI )<br>
)<br>
<br>
then<br>
        System.out.println(&quot;Done Main Rule, total :&quot; + $total);<br>
end<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/How-to-activate-deactivate-a-rule-tp1516088p1516088.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/How-to-activate-deactivate-a-rule-tp1516088p1516088.html</a><br>

Sent from the Drools - User 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></div></div>