Hi,
I've noticed some "interesting" behaviour with the use of no-loop and salience that I wonder if anybody can explain to me?
Given the following rules:-
package drools.debug
rule "Rule 1- (Fired)"
//salience 500
no-loop true
when
$m : Machine ( )
then
System.out.println("DEBUG [Rule 1-]---> Do nothing!");
end
rule "Rule 1a (Fired)"
//salience 400
no-loop true
when
$m : Machine ( )
then
System.out.println("DEBUG [Rule 1a]---> Setting Attribute(\"TEST3\") on Machine");
Attribute a = new Attribute("TEST1", 100);
$m.setAttribute(a);
modify($m);
assert(a);
end
rule "Rule 1b (Fired)"
//salience 300
no-loop true
when
$a : Attribute( name == "TEST1" )
$m : Machine ( attribute == $a )
then
System.out.println("DEBUG [Rule 1b]---> Found!");
end
Assuming only one Machine Fact is present in Working Memory and the salience lines above are commented out "Rule 1- (Fired)", "Rule 1a (Fired)" and "Rule 1b (Fired)" are activated and fired once (and once only). If however the salience values are uncommented rule "Rule 1- (Fired)" is fired twice (even though it is has the "no-loop" attribute). If the salience statements remain but have the same value then the rules only fire once as well (as I'd expect). It appears that "no-loop" only applies to rules with the same salience. Is this correct? Can somebody provide some reason as to why this occurs as it is different to what I'd expect?
With kind regards,
Mike