[rules-users] how to ensure that one rule only is executed once?

Gabor Szokoli szocske at gmail.com
Fri Mar 18 12:08:11 EDT 2011


Hi,

>From what I know, it's generally better to make the rules idempotent:
In your case introduce a discountedPrice field, leaving the original
price alone.

If you insist on making it run only once instead, you can introduce a
field or fact class to mark an order "discounted", then all
discounting rules know to ignore it. (This gets really complicated if
the order amount ever changes and you do need to run the discounting
rules again.)


Gabor

2011/3/18 yong zhao <cluncao at yahoo.com.cn>:
> Hi
> I just try to uses jboss rules in our projects. I met a question. for
> example
> package sample
> rule "rule 1"
> when
>   $o:Order (amount>100 and amount<200);
>  then
> $o.setPrice($o.getPrice()-10);
> end
> rule "rule 2"
> when
>   $o:Order (amount>200);
>  then
> $o.setPrice($o.getPrice()-20);
> end
> if the fact , order's amount is 210. then the rule2 will be executed, then
> the rule1 will be fired . I want to stop the session once some rule is
> executed or how to control the rule flow.
> thanks in advance
> -Yong
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>




More information about the rules-users mailing list