Here is my use case. We are trying to implement a policy sever using Drools. There could be few hundreds thousand (~200K) rules, all based data driven. Few example rules:
POLICY #1: Gender = Male &&
AGE BETWEEN 30 AND 40 &&
BORN_STATE IN (NC,CA,PA)
===> [Outcome = Allow]
POLICY #2: (Gender = Male OR Gender = Female) &&
AGE = 40 &&
COUNTRY IN (USA,UK,BRA, IND)
===> [Outcome = Allow]
POLICY #3: Gender = Female &&
(AGE BETWEEN 10 AND 20 || BORN_YEAR > 1990) &&
BORN_STATE IN (NC,CA,PA) &&
BORN_STATE_SUPPORTIVE = TRUE
===> [Outcome = NotAllow]
NOTE: I am only using 4 parameters here, but there could up to 20 parameters in any given rule
Policy #1 and Policy #2 look simple and straight forward. However, Policy #3 is tricky. The last condition (BORN_STATE_SUPPORTIVE = TRUE) of Policy #3 indicates the States on the policy are "inclusive" which means, if the rule matched, the Outcome would "NotAllow" however, if all parameters matched but NOT BORN_STATE (e.g. Female, Age=15, State=NY) then the Outcome should be "Allow". It's just way for our users not to list all 47 States for this condition.
There are few other usecases:
- Find and prevent duplicate rules while rules maintanence by users
- As I mentioned, there could be thousands of these rules, so if there is a conflict (multiple conflicting rules matched), we should consider the Outcome of high priority rule.
Our users neither like Drools Guvnor nor convinced it's suitable for our need. So, we are tasked to build a custom UI to manage the rules. I am planning to come up with a DSL that our users use and generate DRL file programatically. I am not sure Drools DSL feature would work for this.
I am familiar with Drools and DRL file. However, I am not sure some of the complexity is solvable in Drools (Ex: finding duplicate rules and Policy #3) and, if Drools would be able to handle the load. Any, reference or direction would be greatly appreciated.
Update for BORN_STATE_SUPPORTIVE:
Polic #3 Expected Behavior:
Input #1: Female, Age=15, State=NC
===> [Expected Outcome = NotAllow]
Input #2: Female, Age=25, State=NC
===> [Expected Outcome = <age not in range, rule didn't match>] (Neither NotAllowed Nor Allowed)
Input #3: Female, Age=15, State=NY
===> [Expected Outcome = Allow] (Opposite of NotAllow)
In short, if all other condition matched except BORN_STATE then the outcome must be opposite of rule. And, if any other condition didn't match, the rule must be disregarded.