My drl is:
rule "Active Orders"
dialect "mvel"
//no-loop
when
m: Order( status == Order.ENABLED, id : id )
then
System.out.println( "Order Id is: " + id );
modify ( m )
{
status = Order.DISABLED
};
end
I pass a single Order instance to the drools like this:
Order order = new Order();
order.setId(100);
order.setStatus( Order.ENABLED );
ksession.insert( order );
ksession.fireAllRules();
I am seeing that the rules are fired infinitely with message:
Order Id is: 100
Order Id is: 100
Order Id is: 100
.....
I can understand the infinite-loop, but the key thing is i am setting Order Status to DISABLED in modify block:
status = Order.DISABLED
Therefore, the when rule is fired again....The WHEN condition i.e status == Order.ENABLED , should not be satisfied, and i should not see the system.out.println message more than once.
Any idea, what am i doing wrong?
(Pls note: My problem is not Infinite loop, but why rule is evaluated incorrectly after object modification)