I am new to drools and have defined two rules :
package com.mgaudin.sandbox.drools.rules;
import com.mgaudin.sandbox.drools.models.Lead;
rule "rule1"
when
l: Object()
then
System.out.println(l.getClass().getCanonicalName());
end
And
package com.mgaudin.sandbox.drools.rules;
import com.mgaudin.sandbox.drools.models.Lead;
rule "rule2"
when
Lead()
then
System.out.println("It's a match !");
end
When I insert a new com.mgaudin.sandbox.drools.models.Lead fact, the output is the following :
com.mgaudin.sandbox.drools.models.Lead
Therefore we can deduce that :
So why is the rule "rule2" not matching ?
Thanks !
OK I found the answer and it's not related to Drools, it's related to Spring-boot-devtools !
I don't know the exact mechanism but to enable fast hot reload (even if a method signature changes), spring-boot-devtools must mess with the JVM and proxify some objects, in my case, the fact. Because of this and the way Drools matches fact, the rule did not triggered.
All I had to do was remove the maven dependency to spring-boot-devtools.