[rules-users] Is it possible to affect load order of rules?

Abhay B. Chaware Abhay.Chaware at kpitcummins.com
Thu May 19 02:57:39 EDT 2011


If I understand your problem correctly, you can, may be, flag your MyObj ( add an attribute called flag and set it to some value ) indicating that it has passed "morespecific" rule and add constraint in the "general" rule to ignore such facts ?

-abhay
________________________________
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Martin, Matthias
Sent: Thursday, May 19, 2011 12:20 PM
To: rules-users at lists.jboss.org
Subject: [rules-users] Is it possible to affect load order of rules?

Hello,

in our project we've to know, which rules have already been checked, regardless whether or not the rule gets activated and hence put on the agenda. Is there any possibility to affect the order, in which the drools engine reads and checks the LHS of rules? I suppose the assignment of a salience value has no effect on the load order and is rather a mechanism for conflict resolving, when a rule is about to be fired.
Background for this demand explained in an nutshell:
We use salience for conflict resolving. The conflicting rule with the highest salience value should be fired, but the others with minor salience values mustn't! In our scenario it can occur, that two (or more) rules might conflict at runtime. Therefore we want to perceive, which rule for which fact has already been checked, actually if it gets never activated on the agenda.

Example:
rule "morespecific"
salience 100
when myObj(variant = Variants.SPECIFIC_1 && fee < 10)
then....
end

rule "general"
salience 30
when myObj(fee < 100)
then....
end

If I set the value for variant to Variants.SPECIFIC_1 and the fee value to 30, for example, the first rule will never make it to the agenda but the second one does and is actually getting fired because it doesn't care about the variants value and 30 is less 100.
We want to perceive the already performed check for "morespecific" for a specific object und halt the execution of "general".

Any suggestions are welcome!

Regards,

Matthias Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110519/d398603c/attachment.html 


More information about the rules-users mailing list