Search code examples
datecomparisondrools

Date comparison rule going in Infinite loop


I am trying to execute a set of 5 rules listed below-

Let's say there are two entities- Entity1 and Entity 2. Entity1 contains 3 date type variables - Date1, Date2, Date3 Entity2 contains a date type variables - Date4

  1. Rule 1 - If Date1 > Date2, then throw an Error Message
  2. Rule 2 - If Date2 > Date3, then throw an Error Message
  3. Rule 3 - If Date3 < Date4, then throw an Error Message
  4. Rule 4 - If Date1 > Today's Date, then throw an Error Message
  5. Rule 4 - If Date3 < Today's Date, then throw an Error Message

After a while, I noticed that the logs are growing and the system goes out of memory.

Digging in a bit more I enabled TRACE on org.drools package and found that the rules are going in a loop and not getting stopped.

I am using Drools Workbench 7.2.0 Final

Please suggest how to proceed with this.

Edit - Added snip of the DRL file DRL


Solution

  • As soon as one modify( $passport ) is executed, all rules with matching LHS are liable to be re-fired. no-loop blocks only the rule where the modify was done; it does not inhibit a loop going over two or more rules.

    The best technique to inhibit this kind of loop is to add in all rules a constraint that detects when the modify has been done, e.g.

    Passport( response == null, ... )