My project involves rule creation by customers, business analysts, and developers. We
have a base set of rules that fire for every transaction and then we fire custom rules
within a stateful session. An issue I've started to run into is rules being created
that fire endlessly. I initialize the session with an event listener that we use to
extract all rules fired for each line item of a transaction. Once the session is
initialized and all rules from various agenda groups loaded we do a fireall rules.
My questions are:
1) how can I detect I have a runaway rule/rules.
Is there a method or listener that could detect this for me? Does anyone have a formula
they use to do so? I had thought that I could use my event listener that I track the
rules with to grab the last X number of rules fires and see if rule y gets fired more that
z times. But is there a simpler method?
2) once I've detected a runaway rule, how can I gracefully stop drools rule execution?
I read of the command drools.halt in different posts, but not sure if this would be what
I'm looking at doing.
Any thoughts are appreciated.
Thank you!
Dean
StatefulKnowledgeSession ksession =
buildOutgoingStatefulKnowledgeSession(supportingUDTList);
// AgendaEventListener agendaListener = new HipaaAgendaListener();
ksession.addEventListener(_ruleLog);
for (int i = 0; i < _agendaGroups.size(); i++)
{
if (_log.isDebugEnabled()) _log.debug("Focus on Agenda Group " +
_agendaGroups.get(i));
ksession.getAgenda().getAgendaGroup(_agendaGroups.get(i)).setFocus();
// Fire them all
try
{
ksession.fireAllRules();
}
catch (Exception e)
{
_log.error("FireAllRules exception. Error=" + e.getMessage()); // error
}
}