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

Subhas subhas.sing at gmail.com
Fri Mar 18 18:16:57 EDT 2011


Hi Yong,
   Have you tried with retract the fact after your operation done. Like as
follows

package sample

rule "rule 1"
when
  $o:Order (amount>100 and amount<200);
 then
$o.setPrice($o.getPrice()-10);
        retract($o);
end

rule "rule 2"
when
  $o:Order (amount>200);
 then

$o.setPrice($o.getPrice()-20);
        retract($o);
end


Thanks,
Subhas


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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110318/475cf7be/attachment.html 


More information about the rules-users mailing list