Drools :: Infinite Loops

Attribute no-loop avoid the re-activation of a rule caused by the RHS of that SAME rule.
Attribute lock-on-active avoid the re-activation of a rule NO MATTER what the cause is.

Self-Loop

Modifications of facts can trigger a new activation of the same rule.

Example

Counter.java:

Counter1App.java:

The above generates an infinite loop.
If the modified object ($c) still matches the condition of the rule, it will re-evaluate itself. This leads to an infinite amount of rule executions for the same element.

Complex-Loop

Modifications of facts from within a rule can trigger a different rule that will eventually re-activate the original rule.

Example

In this case, the usage of no-loop is not enough.

Output:

pom.xml:

 

Download

loops.zip

 

Leave a Reply