From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Smitha Bhat
Sent: 05 July 2007 16:43
To: rules-users@lists.jboss.org
Subject: [rules-users] order of rules firingHi,I am new to JBoss rules.My drl file is not resulting in the functionality that I am expecting.I know that I shouldn't be counting on the rules firing in a particular order, but I find that as I debug my code, the 'when' of the 3 rules are evaluated first, and then the 'then's. For eg. the SetWatch gets called after DistanceKm(Rule1), DistanceKm(Rule2) and CountWatching(rule3) are called. I expected SetWatch to get called after DistanceKm of Rule2 got called i.e. I expected the 'when' and the 'then' to get evaluated sequentially. Is my understanding wrong? I tried setting the salience of the 3 rules, but I get the same behaviour. Is there something else I need to do, to get the functionality I need?ThanksThe 3 rules in my drl as given below.rule "Rule1"when$GeoPosition1 : GeoPosition()$GeoPosition2 : GeoPosition()eval(util.StringEqual($GeoPosition1.getType(), "PRPT"))eval(util.StringEqual($GeoPosition2.getType(), "SI"))eval(util.DistanceKm($GeoPosition1, $GeoPosition2) > 100.0)eval(util.Watching($GeoPosition1, $GeoPosition2))thenutil.ClearWatch($GeoPosition1, $GeoPosition2);endrule "Rule2"when$GeoPosition1 : GeoPosition()$GeoPosition2 : GeoPosition()eval(util.StringEqual($GeoPosition1.getType(), "PRPT"))eval(util.StringEqual($GeoPosition2.getType(), "SI"))eval(util.DistanceKm($GeoPosition1, $GeoPosition2) <= 100.0)eval(! util.Watching($GeoPosition1, $GeoPosition2))thenutil.SetWatch($GeoPosition1, $GeoPosition2);endrule "Rule3"when$GeoPosition1 : GeoPosition()eval(util.StringEqual($GeoPosition1.getType(), "PRPT"))eval(util.CountWatching($GeoPosition1) >= 1)thenutil.SetThreat($GeoPosition1, 1.0);util.SetColor($GeoPosition1, "red");end
Got a little couch potato?
Check out fun summer activities for kids.