After some further test, I manage to make the solution based on AgendaEventListener work but ONLY WHEN A NEW SESSION is created.
In my application, i query the sessiontable at startup and I load the existing StatefulSession if I find an entry in this table.
If no previous session was created, I created one (see below)
// check if there is an existing session in the DB
// if a session is found, then restore it else create a new one
int existingSessionId = findLastKnowledgeSessionID();
if (existingSessionId != -1) {
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(existingSessionId, base, kconfig, env);
} else {
ksession = JPAKnowledgeService.newStatefulKnowledgeSession(base, kconfig, env);
}
In case where I load the previous session then the Agenda Event Listener is not triggered...
When I look in the nodeinstancelog table, I can see that the engine enters the Rule node (type = 0) but it hangs.
Any idea ?