I’m writing a technical book on Drools kernel source code analysis. While
analyzing the rule execution process, I would like to discuss a core
calling logic and appreciate your support.
I traced the source with a minimal demo:

kmodule.xml

<kbase name="helloKieBase" packages="rules.ruleHello">
    <ksession name="testhelloworld" />
</kbase>

DRL

package rules.ruleHello
import com.test.drools.pojo.Person;

rule "Identity equality Fact test"
when
    $p:Person()
then
    System.out.println("Identity and equality Fact Person");
end

Java

public static void main(String[] args) {
    KieServices kieServices = KieServices.Factory.get();
    KieContainer kieContainer = kieServices.getKieClasspathContainer();
    KieSession kieSession = kieContainer.newKieSession("testhelloworld");

    Person person = new Person();
    person.setName("张三");
    person.setAge(10);

    kieSession.insert(person);
    kieSession.fireAllRules();
    kieSession.dispose();
}



When debugging the source code:
In RuleExecutor.innerFireActivation:
consequence.evaluate(knowledgeHelper, wm);
But it actually goes into ConsequenceGenerator.generate()

I would like to discuss:
Why does consequence.evaluate lead to ConsequenceGenerator.generate()?
What is the full class & method call chain between them?


Your insights will greatly support my book. Thank you!

Reply via email to