[rules-users] Drools Activation Group

freejava freejava3 at gmail.com
Tue Nov 29 16:54:59 EST 2011


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.


--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Activation-Group-tp3546607p3546607.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list