how to skip other rules based on the value set in the rhs of a rule in drools

Drools version 5.5

I came across the following scenario 

global com.xx.Status status
rule "First rule"
salience 199
when
    $bean : Bean( value == 'ABC')
then
    status.setValue(150);
end

rule "Second rule"
salience 20
when
    $bean : Bean( value == 'ABC')then
    status.setValue(170);end
Actual Results: Rule 'Second Rule' will be fired first and then rule 'First Rule'. 
I want to skip 'First rule' from getting fired since 'Second Rule' is satisfied.
Work Around : Use activation-group feature in Drools. 
The activation-group will cause that only one rule to get executed, the one with higher salience will be executed if it is activated. 
From Drools documentation
activation-group
type: String
Rules that belong to the same activation-group, identified by this attribute's string value, will only fire exclusively. In other words, the first rule in an activation-group to fire will cancel the other rules' activations, i.e., stop them from firing.

No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days