[rules-users] looping due to immediate retraction

John J. Franey jjfraney at gmail.com
Wed Nov 21 09:43:53 EST 2007


OK. It took me a few laps with the debugger to understand what is happening
with the following:

rule
  when
     $assignment: Assignment($resource: resource)
     not Booking(resource == $resource)
  then
     insertLogical(new Booking($resource));
end


Basically, in the rhs the insertion of the new Booking causes the lhs to be
reevaluated, and since in the reevaluation, there IS a Booking, it is
retracted.  Then the lhs is reevaluated to see that there is NOT a Booking,
and so the rhs is run again, and loop and loop and loop.


But what I don't understand, is if I add an update in the rhs like this:


rule
  when
     $assignment: Assignment($resource: resource)
     not Booking(resource == $resource)
  then
    update($assignment);
    insertLogical(new Booking($resource));
end


there isn't a loop.  I didn't take the journey with the debugger to answer
this question, but am still wondering: why does the update  break the
infinite loop?

Thanks,
John

-- 
View this message in context: http://www.nabble.com/looping-due-to-immediate-retraction-tf4847517.html#a13869521
Sent from the drools - user mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071121/c23cb699/attachment.html 


More information about the rules-users mailing list