Dirk, Fixed:
http://jira.jboss.com/jira/browse/JBRULES-1410 Fix will be included in 4.0.4 to be released in the next few days. Thanks for reporting and providing test case. []s Edson 2008/1/9, Edson Tirelli <[EMAIL PROTECTED]>: > > > Dirk, > > It is a bug that affects collect and accumulate. Working on that. > Firing rules is the default behavior when dynamically adding packages. > I think mark created a configuration to change this behavior... > > []s > Edson > > 2008/1/9, Dirk Bergstrom <[EMAIL PROTECTED]>: > > > > I have modified my application to allow adding/removing/updating rules > > during > > runtime. However, when I add a new rule to the rulebase, I don't get > > the > > behavior I expect. > > > > First, as soon as I call RuleBase.addPackage (), the new rules fire (the > > RHS code > > runs). Shouldn't that happen only when I call fireAllRules()? > > > > Second, newly added collect() rules don't collect already asserted > > objects. New > > non-collect rules can see the objects just fine. > > > > Attached is a testcase, and below is the output it produces. Am I doing > > something wrong, or is this a bug? I'm running Drools 4.0.3 on JDK > > 1.5.0.13. > > > > Start > > RuleBase created > > Adding rules about 'tom': > > package rules; > > import java.util.ArrayList; > > import test.Tester.Record; > > import test.Tester; > > rule "Collect tom" > > when > > $list : ArrayList(size > 0) from collect( Record(field1 == "tom") ) > > then > > Tester.show($list, "Collect tom"); > > end > > > > rule "Non collect tom" > > when > > $rec : Record( field1 == "tom" ) > > then > > System.out.println("Find 'tom' " + $rec.dump()); > > end > > > > inserting record 1:"tom", > > inserting record 2:"fred", > > inserting record 3:"harry", > > inserting record 4:"fred", > > inserting record 5:"ed", > > inserting record 6:"tom", > > inserting record 7:"sreeni", > > inserting record 8:"jill", > > inserting record 9:"ralph", > > inserting record 10:"tom", > > > > fireAllRules() > > Find 'tom' 10:"tom", > > 'Collect tom' collected 3 records => 1:"tom", 6:"tom", 10:"tom", > > Find 'tom' 6:"tom", > > Find 'tom' 1:"tom", > > > > adding rules about 'fred': > > package morerules; > > import java.util.ArrayList; > > import test.Tester.Record; > > import test.Tester; > > rule "Collect fred" > > when > > $list : ArrayList(size > 0) from collect( Record(field1 == "fred") ) > > then > > Tester.show($list, "Collect fred"); > > end > > > > rule "Non collect fred" > > when > > $rec : Record( field1 == "fred" ) > > then > > System.out.println("Find 'fred' " + $rec.dump()); > > end > > > > ==> Why do the new rules fire when added? > > Find 'fred' 4:"fred", > > Find 'fred' 2:"fred", > > 'Collect fred' collected 0 records => > > ==> Why doesn't the collect rule collect? The non-collect rule works. > > fireAllRules() > > > > Changing record 3 to 'fred' > > fireAllRules() > > Find 'fred' 3:"fred", > > 'Collect fred' collected 1 records => 3:"fred", > > ==> Why does the collect rule not see the other two 'fred' records? > > > > -- > > Dirk Bergstrom [EMAIL PROTECTED] > > _____________________________________________ > > Juniper Networks Inc., Computer Geek > > Tel: 408.745.3182 Fax: 408.745.8905 > > > > _______________________________________________ > > rules-users mailing list > > [email protected] > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > > > > -- > Edson Tirelli > JBoss Drools Core Development > Office: +55 11 3529-6000 > Mobile: +55 11 9287-5646 > JBoss, a division of Red Hat @ www.jboss.com -- Edson Tirelli JBoss Drools Core Development Office: +55 11 3529-6000 Mobile: +55 11 9287-5646 JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
