In DROOLS Expert I want to skip the ruleflow-group after any one rule is fired (activation-group not working)

StackOverflow https://stackoverflow.com/questions/21783504

  •  11-10-2022
  •  | 
  •  

Question

I have 5 rule groups with multiple rules in each rule group.

rule "R1"  
    dialect "mvel"  
    ruleflow-group 'RG1'    
    lock-on-active true

rule "R2"  
    dialect "mvel"  
    ruleflow-group 'RG1'    
    lock-on-active true

rule "R3"  
    dialect "mvel"  
    ruleflow-group 'RG1'    
    lock-on-active true

rule "AR4"  
    dialect "mvel"  
    ruleflow-group 'ARG2'   
    lock-on-active true

rule "AR5"  
    dialect "mvel"  
    ruleflow-group 'ARG2'   
    lock-on-active true

I insert multiple facts of the same type into the kiesession. 20 of them.
I run fireallrules on the session and all the facts get evaluated correctly.

but now there is a new requirement that if R1 fires then we have to skip the rule group RG1 for that one fact and move on to the ARG2 rules.

I tried to add activation-group 'ACTRG1' to all the rules in rule flow group 'RG1' and activation-group 'ACTRG2' to all the rules in rule flow group 'ARG2' and it didn't fire any of the rules.

I am using DROOLS 6.0.0.Final.

Any help is appreciated. If you need more details I will be happy to provide it.

One more thing is that if I insert one fact at a time into the kiesession then I can use drools.getWorkingMemory().clearRuleFlowGroup("{agenda}"); and it works fine.
But if I use multiple facts then it stops processing the rule-flow-group for all the facts in the session.

Was it helpful?

Solution

Rather than getting tangled in various rule attributes battling with each other, remove lock-on-active and don't add activation-group but think about conditions to make your basic LHS logic do what the requirements say.

If you can state the requirements precisely enough, we can help you work out the details. What you need is complementary conditions that separate R1 from R2 and R3, respectively, and logic that meets the requiement that made you add lock-on-active.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top