[rules-users] [Drools4]: Filter executed rules by *.drl file

magendo robert.heisenberg at yahoo.com
Tue Jul 19 09:53:23 EDT 2011


Before I start do explain my problem I should say that I have already
searched through the older posts and found similiar problems but not exactly
the following one:

My Application has multiple RuleFiles (*.drl each with its own package)
which can be dynamically added/removed. Based on a context (lets say String
foo = "bar") only the rulepackage which fits to "bar" should be executed.
Usually that isnt a problem, because drools just executes the rules with the
fitting facts. But in this case all the rules in the rulepackages check the
same type of facts.

Currently I am using an AgendaFilter (if rulepackage == xyz { accept =
true}) to achieve this goal, but firstly it doesnt effect inserting of facts
(LHS of every rule is executed) and secondly I have read that it should only
be used for unit testing, since it couples java code with rule behavior.

While reading older posts I have found two possible solutions that could
work:

1. Using a contextObject which has foo and is checked in the first rule of
each rulepackage. This first rule and the remaining rules in the rulepackage
have the same agenda group. So if the first rule doesnt fit, the other rules
wont be executed, either (does this really work? ;)).

2. Putting every rulepackge in its own rulebase. Then I would check the
context in java and execute the fitting rulebase.

Let's say I have about 300 *.drl files. Which solution would be better? 

Maybe there is a better solution 3) of which I didnt think yet. Then dont
hesitate and tell it to me :)


Thanks in advance for any help.

--
View this message in context: http://drools.46999.n3.nabble.com/Drools4-Filter-executed-rules-by-drl-file-tp3182568p3182568.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list