<br>&nbsp;&nbsp; Samir, <br><br>&nbsp;&nbsp; I downloaded your code, but it seems incomplete... <br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2008/3/10, samirsss &lt;<a href="mailto:samirsavla@gmail.com">samirsavla@gmail.com</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;">
<br> Hi Edson,<br> <br> I tried the exact method you asked me to and seems like now i am getting an<br> error while I add the rule. Also the rules still dont get fired.<br> <br> I&#39;m going to send you the code again and maybe you can fix it and send it<br>
 back to me after testing that all 3 scenarios for the messageId = Test,<br> Test2 and Test3 pass.<br> <br> thanks<br> Samir<br> <br> <a href="http://www.nabble.com/file/p15950841/TestDynamicRules.zip">http://www.nabble.com/file/p15950841/TestDynamicRules.zip</a><br>
 TestDynamicRules.zip<br> <br><br> Edson Tirelli-3 wrote:<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;Samir,<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;I had a look at the code you sent me and the problem is that you are<br> &gt; not<br> &gt; adding the rule to the rulebase. In your<br>
 &gt; ConnectionHandler.testDynamicRules()<br> &gt; method, you need to do:<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ruleBase.addPackage( builder.getPackage() );<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;You probably incurred in this error because you are misusing the<br>
 &gt; Package<br> &gt; objects. You should either remove the whole package from the rule base<br> &gt; before doing your merge or, what I think is best, create a package with<br> &gt; the<br> &gt; &quot;delta&quot; rules you want to add.<br>
 &gt;&nbsp;&nbsp;&nbsp;&nbsp;So, instead of doing:<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Package defaultPackage = pkg[0];<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;Do:<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Package defaultPackage = new Package( pkg[0].getName() );<br> &gt;<br>
 &gt;&nbsp;&nbsp;&nbsp;&nbsp;So, you are effectively creating a new Package object, but when you add<br> &gt; it to the rule base, it will be correctly merged into the existing one.<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;This also allows you to AVOID the lock you are doing here:<br>
 &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ruleBase.lock(); // no need for that if you use a new<br> &gt; package<br> &gt; with the same name<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;packageDescr.addRule( ruleDescr );<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;builder.addPackage(packageDescr);<br>
 &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ruleBase.unlock(); // no need for that if you use a new<br> &gt; package with the same name<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;Hope it helps.<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br> &gt;<br> <br>--<br> View this message in context: <a href="http://www.nabble.com/Cant-seem-to-fire-a-dynamically-added-rule-tp15810172p15950841.html">http://www.nabble.com/Cant-seem-to-fire-a-dynamically-added-rule-tp15810172p15950841.html</a><br>
 <br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br> <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> </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>