[rules-users] Use only first matching rule

Dr. Gernot Starke gs at gernotstarke.de
Tue Oct 30 04:06:08 EDT 2007


Georgy,

one (simple) way to achieve this is to assert a "stop"-fact on the  
right-hand-side
of the executing rule (e.g. by setting an appropriate attribute)  AND  
querying that attribute on the LHS of every rule.

Example (pseudo-code)

rule 1
   when (business-conditions...)
	st: StopFact ( done == false )
   then
         st.setDone( true ); // make ALL other rules fail
         // all other actions...
end

IMHO this is expressive in a way that the "single-rule-only" approach  
is clearly visible in all rules...

But: Don't forget to set the StopFact to "not-done" after evaluation...

regards from Cologne,
Gernot


Am 30.10.2007 um 08:21 schrieb nechukin:

>
> Hi,
>
> I'm looking into the Drools engine for our application, and looks  
> like it's
> satisfies the reqirements. The only thing I haven't found still is a
> following conflict management model:
>
> If rule_1 (with highest salience) is applicable, STOP applying another
> rules.
>
> So the essence is that only 1 or 0 rules should be applied for the
> particular entity, not 2 or more.
>
> I'm sure this is supported by engine. Where to look? Tried to scan
> ConflictResolving section, but look like it is only about the rules
> application order, not more...
>
> Thanks,
> Georgy
> -- 
> View this message in context: http://www.nabble.com/Use-only-first- 
> matching-rule-tf4710521.html#a13464084
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>

Dr. Gernot Starke
Doing IT Right

---
Willi-Lauf Allee 43, D-50858 Köln
gs at gernotstarke.de,
  +49 (0) 177 - 728 2570
http://www.gernotstarke.de
Blog: http://it-and-more.blogspot.com
****************************************
Das freie Portal für Software-Architekten:
http://www.arc42.de






More information about the rules-users mailing list