thanks , Both are possible ways for the issue though they are a little complicated.
________________________________ 发件人: Michael Anstis <[email protected]> 收件人: Rules Users List <[email protected]> 发送日期: 2011/3/19 (周六) 12:25:48 上午 主 题: Re: [rules-users] how to ensure that one rule only is executed once? You'd need to make sure you inform the engine that Order's price has changed:- when ... then modify( $o ) { setPrice( $o.getPrice() - 20); } You could also consider using agenda-groups or lock-on-active to provide your behaviour. agenda-groups rule "rule 1" //implied default agenda-group of MAIN when $o : Order (amount>100 && <200); then modify( $o ) { setPrice( $o.getPrice() - 10); } drools.setFocus("next step in calculation"); end rule "rule 2" //implied default agenda-group of MAIN when $o:Order (amount>200); then modify( $o ) { setPrice($o.getPrice() - 20); } drools.setFocus("next step in calculation"); end rule "rule 3" agenda-group "next step in calculation" when $o : Order(....) then .... end lock-on-active rule "rule 1" //implied default agenda-group of MAIN lock-on-active true when $o : Order (amount>100 && <200); then modify( $o ) { setPrice( $o.getPrice() - 10); } end rule "rule 2" //implied default agenda-group of MAIN lock-on-active true when $o:Order (amount>200); then modify( $o ) { setPrice($o.getPrice() - 20); } end rule "rule 3" agenda-group "next step in calculation" when $o : Order(....) then .... end On 18 March 2011 16:08, Gabor Szokoli <[email protected]> wrote: 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 <[email protected]>: > >> 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 >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > >_______________________________________________ >rules-users mailing list >[email protected] >https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
