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.
Asked
Active
Viewed 758 times
-2
-
@JeroenHeier I haven't written it yet....this is the requirement given to me...Right now I'm checking whether it can be done by drool or not... – pratik2392 Jul 28 '16 at 04:26
-
Ok. So what is stopping you from doing that, i mean what is the problem, where are you stuck – Maverick Jul 28 '16 at 05:55
-
@Maverick I'm new to drools and I don't know how to do that or if it is possible to implement or not...So what I need is a little guidance how to implement the same in Drool if it is possible... – pratik2392 Jul 28 '16 at 06:49
-
It is possible if you know which rules apply to customer X and which facts (fact types) are applicable to a particular rule set. - It might be preferable to have one (fact) database for each customer. – laune Jul 28 '16 at 07:09
1 Answers
0
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.

raphaëλ
- 6,393
- 2
- 29
- 35
-
ok...but I don't see how it solves my problem....Here you have taken an example of 2 customers...Lets take a scenario where we have 3 customers A,B, and C. There are 10 rules, in which 5 rules are for A, 4 rules are for B, and 6 rules are for C. ABC all have some rules which are only applicable to them I don't know which are those rules, some rules are common to all and some are common to AB and BC. I know which customer has logged in when the app starts. So based on that I want to get the list of rules to be fired from drl and list of facts which will be needed to fire them. – pratik2392 Jul 28 '16 at 11:46