<b>Issue:</b>

By looking in the Drools source code i found something interesting...<br>

When you call <font color='grey'>session.getRuleBase().addPackage(<i>yourPackage</i>)</font> an event of type <font color='grey'>AfterPackageAddedEvent</font> is sent to all RuleBaseListener of the RuleBase. It appear that one of this listener is added by default, which is : <font color='grey'>org.drools.base.FireAllRulesRuleBaseUpdateListener.</font><br>

This listener when receiving an event of this type, call the following method:<br>
<br>
public void beforeRuleBaseUnlocked(BeforeRuleBaseUnlockedEvent event) {<br>
    if ( session.getRuleBase().getAdditionsSinceLock() > 0 ) {<br>
        session.fireAllRules();<br>
    }<br>
} <br><br>

and so call fireAllRules(); !! this imply that if  you have cycling rules inside you rule package you will never leave the 
session.getRuleBase().addPackage(<i>yourPackage</i>) call.....<br><br>

<b>Solution:</b>

<ul>
<li>One solution would be to remove this listener by defaut and add one with an overloading of the beforeRuleBaseUnlocked method.</li>

<li>A better solution i think, would be to be able to set a default <b>fireLimit</b> option on session, so a call to fireAllRule would use this defaultFireLimit. What do you think ?</li>

<li> is there a better solution ? do i miss something ?</li>
</ul>
<br>
Give me your point on it,

Rémi

<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">Remi Barraquand wrote:</div>
<div class="quote-message">
Hi there,

I'm developing a library that uses drools as a <b>REAL-TIME rule engine</b>. What i'm a doing right now is to have a thread that wakes up each 100ms and do a <b>fireAllRules(1000)</b>.

I need to be able to load Facts and Rules on the fly, even after the statefullsession is created. The problem is that when i add a new RulePackage to the current rulebase's session, all the rules inside this package are evaluated ! and so i never exit from this addPackage function !!

System.out.println("Start loading rules");

// build builder package configuration
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
conf.setClassLoader(factionary);

// Load file
File file = new File(chooser.getSelectedFile().getPath());
PackageBuilder builder = new PackageBuilder(conf);

builder.addPackageFromDrl(new FileReader(file));

// Load package to session
session.getRuleBase().addPackage(builder.getPackage()); // <b>GET STUCK HERE !!!!!!!!!!!</b>

// Print success
jTextArea2.append(chooser.getSelectedFile().getPath()+"\n");
jTextArea2.setCaretPosition(jTextArea1.getDocument().getLength());

System.out.println("Done loading rules");

What i want is just to add the rules from the package that's all.... Since i've a thread that call fireAllRules(1000) each 100ms the rules will get proceced next time :)

Do you have any idea of how to do that ?

Thanks.

Barraquand Rémi

</div>
</div></blockquote>

<b>Issue</b><div class="signature">________________________________________
<br>Rémi Barraquand, PhD I.N.P.G
<br>Projet PRIMA - Laboratoire &nbsp;LIG
<br>INRIA Grenoble Rhones-Alpes Research Centre
<br>655 Ave de l'Europe
<br>38330 Montbonnot, France</div>
<br><hr align="left" width="300">
View this message in context: <a href="http://www.nabble.com/Don%27t-process-rules-when-adding-new-package-to-rulebase-tp17508315p17512452.html">Re: Don't process rules when adding new package to rulebase</a><br>
Sent from the <a href="http://www.nabble.com/drools---user-f11823.html">drools - user mailing list archive</a> at Nabble.com.<br>