If you run the DRL shown below, you will see that rules 2 and 3 activate and log a message. If you then comment out rule 3 in the DRL (you must put the entire rule inside /* */ characters rather than simply disabling it), and rerun it, you'll notice that rules 1 and 2 fire. How is it that the presence of rule 3 affects whether or not rule 1 activates? These two rules are not dependent in their DRL. If you look at the generated Rete trees for each example, you will notice that they differ.
With all three rules active I get:
[main]::INFO ::DroolsTest::test 3 hit on RecordA( id=100 ) - RecordB( id=100, role=2 )
[main]::INFO ::DroolsTest::test 2 hit on RecordA( id=100 ) - RecordB( id=100, role=1 )
With rule 3 commented out I get:
[main]::INFO ::DroolsTest::test 2 hit on RecordA( id=100 ) - RecordB( id=100, role=1 )
[main]::INFO ::DroolsTest::test 1 hit on RecordA( id=100 ) - RecordB( id=100, role=1 )
Interestingly, if you comment out rule 2 so only rules 1 and 3 are active, rule 1 fires again:
[main]::INFO ::DroolsTest::test 3 hit on RecordA( id=100 ) - RecordB( id=100, role=2 )
[main]::INFO ::DroolsTest::test 1 hit on RecordA( id=100 ) - RecordB( id=100, role=1 )
Environment: Drools 5.4.0
package tests
import org.apache.log4j.Logger;
global Logger log
declare RecordA
id : long
end
declare RecordB
id : long
role : String
end
rule "insert data 1"
salience 99999
when
then
insert (new RecordA(100));
insert (new RecordB(100, "1"));
insert (new RecordB(100, "2"));
end
rule "test 1"
when
a : RecordA( )
b : RecordB( id == b.id, role == '1' )
then
log.info(String.format("%s hit on %s - %s", kcontext.getRule().getName(), a, b));
end
rule "test 2"
when
a : RecordA( )
b : RecordB( id == b.id, role == "1" )
then
log.info(String.format("%s hit on %s - %s", kcontext.getRule().getName(), a, b));
end
rule "test 3"
when
a : RecordA( )
b : RecordB( id == b.id, role == "2" )
then
log.info(String.format("%s hit on %s - %s", kcontext.getRule().getName(), a, b));
end