Reputation: 11
I am using guided rule in business central, Modiying the fact in action part with no-loop true . Still the looping is happening . when I use lock-on-active the rule do not run at all. Please help.
rule "today true and close time is before 15pm"
dialect "mvel"
salience 120
ruleflow-group "gogo"
no-loop true
lock-on-active true
when
v : VendorWorkingDays( eval( vendorWD contains(java.time.LocalDate.now().plusDays(1).getDayOfWeek().toString()) )&& todayFlag == true && eval( closeTime.isBefore(java.time.LocalTime.parse("15:00:00")) ))
then
modify( v ) {
setTodayOneE( "NA" ),
setTodayOneM( "Available" ),
setTodayOneFlag( true )
}
System.out.println("today true and close time is before 15pm");
end
Upvotes: 1
Views: 917
Reputation: 6322
You may want to take a look at this other question: what is the difference between no-loop and lock-on-active in drools
In your case, the use of modify
is causing the rules related to the VendorWorkingDays
to be re-evaluated. The use of no-loop
only works for when you have a single rule looping. I guess that in your case, you may have multiple rules involved in the infinite loop.
The use of lock-on-active
will prevent the execution of this rule if the VendorWorkingDays
is being inserted into the session (or modified) from another rule.
There is a link to a blog post in the question I mentioned that will give you a better explanation about these two attributes (the blog post is quite old, but the principles are still more or less valid for the latest version of Drools).
Upvotes: 1