Hi Smitha,
The "when" part of rules causes activations to be created on an agenda
at the time the facts are asserted.
When a call to fireAllRules() is made, activations on the agenda are
fired (the "then" part of the rule). The order in which the activations
are executed is governed by "conflict resolution" strategies.
If you want the "then" part of your rules to fire in a certain sequence
look at "salience" (the simplest form), or Agenda Groups and RuleFlow
(in increasing levels of complexity).
Good luck - JBoss Rules (or whatever new name it might be given - Mark?)
is an excellent product that I am sure you will enjoy using.
With kind regards,
Mike
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Smitha Bhat
Sent: 05 July 2007 16:43
To: rules-users(a)lists.jboss.org
Subject: [rules-users] order of rules firing
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.
<
http://us.rd.yahoo.com/evt=48248/*http://search.yahoo.com/search?fr=oni
_on_mail&p=summer+activities+for+kids&cs=bz>