Hello Drools Experts,
I have a question on activation group and trying to understand the mechanism.
I have the following rules in a .drl file :
import function com.test.utils.StringUtil.isEmpty;
import function com.test.utils.Logger.log;
rule "r1"
salience 10
activation-group "fireOnlyOnce"
when
SomeObject($s: someStringKey)
eval(isEmpty($s) // static java method imported as function
then
log("doSomething");
end
rule "r2"
activation-group "fireOnlyOnce"
when
SomeObject($s: someStringKey)
eval(checkWithDB($s) // Make a call to the DB to validate someStringKeyis valid
then
log("doSomething");
end
In "r1" I am checking for 'someStringKey' is not null or empty. In "r2" , I am making a call to the DB to check 'someStringKey' is a valid id. During the debug,
I found out that both "r1" and "r2" is fired but only one consequence
is executed depending on the outcome of the r1. I want "r2" to fire only when "r1" evaluates to false. How can I achieve this in Drools?
Thanks for your time and appreciate your help.