[rules-users] order of rules firing

Smitha Bhat bhat_smitha at yahoo.com
Thu Jul 5 11:43:07 EDT 2007


Hi,
  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?
   
  Thanks
   
  The 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))
  then
  
  util.ClearWatch($GeoPosition1, $GeoPosition2);
  end
   
  rule "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))
  then
  
  util.SetWatch($GeoPosition1, $GeoPosition2);
  end
   
  rule "Rule3"
  when
  $GeoPosition1 : GeoPosition()
  eval(util.StringEqual($GeoPosition1.getType(), "PRPT")) 
  eval(util.CountWatching($GeoPosition1) >= 1)
  then
  
  util.SetThreat($GeoPosition1, 1.0);
  util.SetColor($GeoPosition1, "red");
  end

       
---------------------------------
Got a little couch potato? 
Check out fun summer activities for kids.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070705/38f59d6c/attachment.html 


More information about the rules-users mailing list