All three rules fire correctly with 5.2.0 and 5.3.0, irrespective of the quotes used to delimit strings. I've seen and reported other problems with 5.4.0.
-W On 22/09/2012, bdolbeare <[email protected]> wrote: > Drools is not producing consistent results in the following example. 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. > > It appears to be related to the fact that rule 1 uses single quotes instead > of double quotes. If you change that, then Drools starts behaving > consistently. This makes me believe that the problem is somehow related to > how Drools is building the Rete tree with the single quotes. > > > > 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 > > > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Drools-Rule-Evaluations-are-Inconsistent-tp4019900.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
