How does update function works in drools? Does it cause the same rules fire again automatically?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you need to read the manual: http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html_single/
Using
updatemakes the rules engine aware that a fact has been modified. Therefore rules which depend upon that fact must be re-evaluated. This does have the effect that a rule may fire in an endless cycle. For instance, given the following DRL, you will see that the “Infinite loop” rule will activate continuously:This is because the rules engine has been instructed by
update($question), that$questionhas changed and that it needs to re-evaluate it.There are ways of preventing this though. Just put
no-loopon the line between the rule name andwhento prevent rules from re-activating as a result of their own consequences. Another rule attribute which can control this islock-on-active.