Greetings, everyone!
I would like to get some advice/guide from you on storing/loading rules
in/from a database.
Here is my use case, in my domain object model, there is a class named
Promotion, and for each instance of Promotion (there could be thousands
promotions), I need to configure one or more rules for the promotion, so
there is a one-to-many relation between the promotion and its rules. I plan
to store the rules in the same DB as Promotion and also maintain the
one-to-many relation between them. At runtime, when facts are inserted, all
promotions' rules need to be evaluated, and I'd like the firing rules to
know their "owning" promotion instances and take some action on those
instances.
And here are my questions/confusions:
1. Do I need to create my own tables for storing rules/conditions/actions OR
can I use the Drools Repository? (Remember I have to keep the relation
between a promotion and its rules)
2. If I need to create my own tables, how should I load the rules at
runtime? The only way I can think of right now is something like string
concatenation and end up with the DRL source format and then use the
PackageBuilder. Would this work? Is there any better ways?
3. At runtime, I need to evaluate ALL the rules to find which promotion(s)
will match, so do I just create a single RuleBase, add all the packages
(there could be tens of thousands of rules), then create the session and
insert the fact and then fire them? Will this cause any performance issue?
What is the best practices to deal with large number of rules?
Thanks in advance.
Tong
Show replies by date