How to dynamically select drools rules for execution at business rule task level?

263 views Asked by At

I've few drools rules that I want to use in different rule flows. Since, Drools rule supports only one ruleflow-group name at a time and rule flow business rule task also can be mapped with single ruleflow-group, I'm not able to use same rule in different rule flows. Is there any other way that I can use to filter the rules? like using tags or and metadata?

1

There are 1 answers

0
Master Drools On

You could create your own rule groups. You create a class OwnRuleGroup with String group in it as a field. Then when you fire rules you create an instance of your own rule grup:

OwnRuleGroup myGroup = new OwnRuleGroup();
myGroup.group = "foo";

and insert it into session with other facts. In every rule you could specify which of the groups you want to fire.

rule "This will fire for groups foo,bar"
when 
  OwnRuleGroup(group in ["foo", "bar"])