[rules-users] strategy for rulebase updates in a cluster?

Marina ppine7 at yahoo.com
Wed Aug 20 11:39:24 EDT 2008


Hello,
I'm integrating DRools into a J2EE application and need to understand how it behaves in a multi-threaded distributed environment. I have many questions about thread safety but for now I'll ask about clustering only and post other questions separately.

So, as I understand, Drools per se is not cluster-aware. In my current design I have a singleton class, RuleEngineMAnager, that holds a reference to a RuleBase. Hence, there will be one instance of a rulebase per JVM per machine in a cluster. Rules can be added/modified from any node in the cluster, and the modifications have to me made visible in all rulebases.
The way I handle it now is by using a DB as the shared unit and setting up a flag when modifications are made in any JVM. Next time a request comes in for the rule engine to run all rule , the flag is checked and the RuleBase is updated.

So, my question is about how to handle the rulebase updates most efficiently.
I see two possibilities:
1. ditch the rulebase completely, build a new Package of rules , create a new rulebase and add the package to it

2. Use the same rulebase - just remove the old package of rules and load in the new one.

The issues here are:
-- what if there are operations going on in the rule engine, invoked from other threads, at the time I want to do either 1 or 2? 

Say, in the scenario #2, the rule engine is running all rules in one  thread. At the same time I'm asking it to drop the rule package from another thread and add the new one. Is it going to finish running all rules with the old package, return results, and only then do the update of the package?

And in the scenario #1, if the rule engine is running the rules, and I try to destroy the old rule base - are those operations sequential?

Any suggestions as to how to design this functionality in the most efficient and safe way?

thank you!
Marina Popova



More information about the rules-users mailing list