no-loop only prevents loops generated by the same rule. In your scenario, Rule A is triggering Rule B, which in turn is triggering Rule A, which is triggering Rule B... and so on.
Try using lock-on-active instead: http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e3573 <http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e3573>Best Regards, XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2011/3/23 Anderson Neves <[email protected]> > Hi. > > I like to add negated attributes in the condition, or other attributes that > better describe the object state, like below. If you write two rules to the > same object state, you should think to join the rules into one rule. > > rule > when > $object:Type(attribute=="value", secondAttribute == false, > thirdAttribute == "") > then > // do consequence > end > > Regards, > Anderson > > > 2011/3/23 Gabor Szokoli <[email protected]> > >> This is I think something all of us came across while learning Drools... >> >> So I searched for "drools loop faq" in google but nothing useful came up. >> I propose to extend the "inifinite recursion" section in the faq with >> the best practices for avoiding this! >> >> My favorite way to avoid unnecessary activations is to include the >> consequence among the conditions, negated: >> >> rule >> when >> $object:Type(attribute!="value") >> then >> modify ($object) { setAttribute("value")} >> end >> >> >> Gabor >> >> On Wed, Mar 23, 2011 at 12:30 PM, James Gu <[email protected]> >> wrote: >> > Hi, I am working on rule and found that it is very easy to cause endless >> > loop. >> > >> > For example: >> > Rule 1 match status and update message. >> > Rule 2 match type and update message. >> > This will cause endless loop even I add "no-loop" on each rule. Is there >> > anyway to avoid this? for example: each rule only execute one time, or >> set a >> > maximum execute times. >> > >> > >> > rule "rule 1" >> > no-loop >> > when >> > m : Message( status == Message.HELLO) >> > then >> > System.out.println( "rule 1" ); >> > m.setMessage( "update 1" ); >> > update( m ); >> > >> > end >> > >> > rule "rule 2" >> > no-loop >> > when >> > m:Message( type=="type1" ) >> > then >> > System.out.println( "rule 2" ); >> > m.setMessage( "update 2" ); >> > update( m ); >> > end >> > >> > -- >> > View this message in context: >> http://drools-java-rules-engine.46999.n3.nabble.com/endless-loop-even-with-no-loop-tp2719917p2719917.html >> > Sent from the Drools - User mailing list archive at Nabble.com. >> > _______________________________________________ >> > 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 > >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
