First:

According to the drools docs: "Only rules in the agenda group that has acquired 
the focus are allowed to fire."

Salience is an inter-rule directive, affecting the execution order between two 
rules that are currently eligible to fire.  Since only one agenda-group can be 
active at once, by definition the saliences of rules in different groups have 
no bearing on each other.

If you want to dictate the execution order of groups of rules I'd suggest using 
ruleflows and ruleflow-group.  With those you have far more nuance and control 
than just simple salience.  Because of that I doubt there would be any addition 
of an "agenda group salience" feature, unless you write it.  

Second:

Did you intend to add lock-on-active to rule3?  You seem to imply that.  If so, 
and if you intend rule3 to be default salience, it makes sense that rule3 would 
fire and not rule2.  rule3 fires first because of it's higher salience, and 
then the activation of rule2 is discarded because of lock-on-active.  If you 
want rule2 to fire first, and not rule3, you will have to flip their salience 
order.  If you want both to fire, but just once, (unless the matched properties 
in the LHS are changed) then use no-loop.  I'm not sure from what you've 
written that you want another behavior. 

--- On Mon, 12/28/09, oknuutti <olli.knuutt...@gmail.com> wrote:

> From: oknuutti <olli.knuutt...@gmail.com>
> Subject: [rules-users] suprises when using auto-focus with salience or 
> lock-on-active
> To: rules-users@lists.jboss.org
> Date: Monday, December 28, 2009, 4:29 AM
> 
> While evaluating Drools 5.1.0 M1, I came across two issues
> which strike me
> somewhat undesirable. Maybe there's good reasons why they
> exist; perhaps I'm
> missing something?
> 
> First:
> 
> If I have two agenda groups, each with a rule that has
> auto-focus set to
> true and different saliences, the group which will get the
> focus first seems
> to be determined by the order in which the auto-focused
> rules appear in the
> drl-file, not by their salience.
> 
> // example snippet:
> rule "rule1"
> salience 0
> agenda-group "group1"
> auto-focus true
> when
> then
>     System.out.println("rule1 fired");
> end
> 
> rule "rule2"
> salience -100
> agenda-group "group2"
> auto-focus true
> when
> then
>     System.out.println("rule2 fired");
> end
> 
> // output of the example:
> rule2 fired
> rule1 fired
> 
> If I change the salience of rule2 to 100 the result is
> still the same. It
> seems reasonable to me that the salience would be taken
> into account also in
> this situation.
> 
> Second:
> 
> This issue is with auto-focus and lock-on-active. If I add
> "lock-on-active
> true" to rule2 and also a third rule:
> 
> // continuing the earlier example:
> rule "rule3"
> agenda-group "group2"
> when
> then
>     System.out.println("rule3 fired");
> end
> 
> then I get the following puzzling output:
> 
> rule3 fired
> rule1 fired
> 
> It seems that auto-focus activates the agenda group first
> and then tries to
> activate rule2 but the activation is discarded by
> lock-on-active. I feel
> that this is a bit too strong loop prevention. I would
> rather see rule2
> fired once, with no consecutive activations in the case
> that it would have
> some conditions that were changed by rule3.
> 
> Any comments?
> 
> Olli
> -- 
> View this message in context: 
> http://n3.nabble.com/suprises-when-using-auto-focus-with-salience-or-lock-on-active-tp101839p101839.html
> Sent from the Drools - User mailing list archive at
> Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 


      

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to