tags:

views:

52

answers:

2

What is the outcome of several rules having the same salience? Is their order of execution just the order that they're listed in, or is that behaviour undefined - that is, are they checked in arbitrary order? I can't seem to find documentation of how this is handled internally.

+2  A: 

The short answer is that you shouldn't rely on the order of rules firing of the same salience - if they are "in conflict" (ie both are eligible to fire). Rules with no salience are just salience of zero, BTW.

Of course it is deterministic - its just that the algorithm is subject to change between versions (not very likely though).

This is under the general area of "conflict resolution" and much has been written about it. I can't find a current article on Drools strategy - but I believe most of it is "recency" - ie the most recently modified/inserted fact "wins" - or rather the rules that refer to the most recent fact will win. If after all that it can't decide - it is usually the order in which they rules are loaded (which usually co-incides with how they are written in the file). If you have to have an order - use salience, or use rule-flow or similar, best not to second guess how it will work.

Michael Neale
I'm not really interested in it from a production standpoint - I understand the purposes of salience and I'd never be relying on a certain implementation firing them in a certain order. It's simply a point of interest for me to know if the behaviour is defined at all. Cheers for your answer!
JBirch