问题
Suppose I have 1000 rules in drool and 20 customers. I want to fire those rules which are specific to a customer. It is possible that one rule is applicable for more than on customer. I know which customer is using the application so based on that I want to get list of rules applicable for the customer and list of the facts I need to get from the db to fire those rules. After getting both lists first I'll get the values from db and than fire all the rules for that particular customer.
回答1:
The best way forward here is to use some smart packaging. Place rules exclusive to a customer in their own package. Different sets of shared rules can be placed in other packages.
You would for example define the kbases as follows:
<?xml version="1.0" encoding="UTF-8"?>
<kmodule
xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="acme"
packages="com.dunder.rules.acme, com.dunder.rules.paper">
<ksession name="acmeSession" type="stateless"/>
</kbase>
<kbase name="pipepiper"
packages="com.dunder.rules.pipepiper, com.dunder.rules.paper">
<ksession name="piedpiperSession"type="stateless" />
</kbase>
</kmodule>
The above would have rules for "Acme" and "Pied Piper" while both using "Paper" rules.
来源:https://stackoverflow.com/questions/38626569/get-list-of-facts-from-rule