java - Drools: Why does this rule fire incorrectly? -


my drl is:

rule "active orders"     dialect "mvel"     //no-loop     when         m: order( status == order.enabled, id : id )             system.out.println( "order id is: " + id );         modify ( m )          {              status = order.disabled           }; end 

i pass single order instance drools this:

order order = new order(); order.setid(100); order.setstatus( order.enabled ); ksession.insert( order );  ksession.fireallrules(); 

i seeing rules fired infinitely message:

order id is: 100 order id is: 100 order id is: 100 ..... 

i can understand infinite-loop, key thing setting order status disabled in modify block:
status = order.disabled

therefore, when rule fired again....the when condition i.e status == order.enabled , should not satisfied, , should not see system.out.println message more once.

any idea, doing wrong?
(pls note: problem not infinite loop, why rule evaluated incorrectly after object modification)

the syntax in modify block wrong (actually i'm not sure why compiles , doing). try this:

modify(m){     setstatus(order.enabled); } 

hope helps,


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -