<br>&nbsp;&nbsp;&nbsp; Dirk, <br><br>&nbsp;&nbsp;&nbsp; It is a bug that affects collect and accumulate. Working on that.<br>&nbsp;&nbsp;&nbsp; Firing rules is the default behavior when dynamically adding packages. I think mark created a configuration to change this behavior...
<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2008/1/9, Dirk Bergstrom &lt;<a href="mailto:dirk@juniper.net">dirk@juniper.net</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have modified my application to allow adding/removing/updating rules during<br>runtime.&nbsp;&nbsp;However, when I add a new rule to the rulebase, I don&#39;t get the<br>behavior I expect.<br><br>First, as soon as I call RuleBase.addPackage
(), the new rules fire (the RHS code<br>runs).&nbsp;&nbsp;Shouldn&#39;t that happen only when I call fireAllRules()?<br><br>Second, newly added collect() rules don&#39;t collect already asserted objects. New<br>non-collect rules can see the objects just fine.
<br><br>Attached is a testcase, and below is the output it produces.&nbsp;&nbsp;Am I doing<br>something wrong, or is this a bug?&nbsp;&nbsp;I&#39;m running Drools 4.0.3 on JDK <a href="http://1.5.0.13">1.5.0.13</a>.<br><br>Start<br>RuleBase created
<br>Adding rules about &#39;tom&#39;:<br>package rules;<br>import java.util.ArrayList;<br>import test.Tester.Record;<br>import test.Tester;<br>rule &quot;Collect tom&quot;<br>when<br> $list : ArrayList(size &gt; 0) from collect( Record(field1 == &quot;tom&quot;) )
<br>then<br> Tester.show($list, &quot;Collect tom&quot;);<br>end<br><br>rule &quot;Non collect tom&quot;<br>when<br> $rec : Record( field1 == &quot;tom&quot; )<br>then<br> System.out.println(&quot;Find &#39;tom&#39; &quot; + $rec.dump());
<br>end<br><br>inserting record 1:&quot;tom&quot;,<br>inserting record 2:&quot;fred&quot;,<br>inserting record 3:&quot;harry&quot;,<br>inserting record 4:&quot;fred&quot;,<br>inserting record 5:&quot;ed&quot;,<br>inserting record 6:&quot;tom&quot;,
<br>inserting record 7:&quot;sreeni&quot;,<br>inserting record 8:&quot;jill&quot;,<br>inserting record 9:&quot;ralph&quot;,<br>inserting record 10:&quot;tom&quot;,<br><br>fireAllRules()<br>Find &#39;tom&#39; 10:&quot;tom&quot;,
<br>&#39;Collect tom&#39; collected 3 records =&gt; 1:&quot;tom&quot;, 6:&quot;tom&quot;, 10:&quot;tom&quot;,<br>Find &#39;tom&#39; 6:&quot;tom&quot;,<br>Find &#39;tom&#39; 1:&quot;tom&quot;,<br><br>adding rules about &#39;fred&#39;:
<br>package morerules;<br>import java.util.ArrayList;<br>import test.Tester.Record;<br>import test.Tester;<br>rule &quot;Collect fred&quot;<br>when<br> $list : ArrayList(size &gt; 0) from collect( Record(field1 == &quot;fred&quot;) )
<br>then<br> Tester.show($list, &quot;Collect fred&quot;);<br>end<br><br>rule &quot;Non collect fred&quot;<br>when<br> $rec : Record( field1 == &quot;fred&quot; )<br>then<br> System.out.println(&quot;Find &#39;fred&#39; &quot; + $rec.dump());
<br>end<br><br> ==&gt; Why do the new rules fire when added?<br>Find &#39;fred&#39; 4:&quot;fred&quot;,<br>Find &#39;fred&#39; 2:&quot;fred&quot;,<br>&#39;Collect fred&#39; collected 0 records =&gt;<br> ==&gt; Why doesn&#39;t the collect rule collect? The non-collect rule works.
<br>fireAllRules()<br><br>Changing record 3 to &#39;fred&#39;<br>fireAllRules()<br>Find &#39;fred&#39; 3:&quot;fred&quot;,<br>&#39;Collect fred&#39; collected 1 records =&gt; 3:&quot;fred&quot;,<br> ==&gt; Why does the collect rule not see the other two &#39;fred&#39; records?
<br><br>--<br>Dirk Bergstrom&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:dirk@juniper.net">dirk@juniper.net</a><br>_____________________________________________<br>Juniper Networks Inc.,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Computer Geek<br>Tel: 408.745.3182&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax: 
408.745.8905<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">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>