I'm trying to return the numbers of retracts that a drools session execution have.
I can obtain the number of executions:
...
final Command fireAllRulesCmd = CommandFactory.newFireAllRules("executed-rules");
cmds.add(fireAllRulesCmd);
...
session.execute(CommandFactory.newBatchExecution(cmds));
final Integer executedRules = (Integer) execute.getValue("executed-rules");
....
Are there a similar way to obtain all "retracted-rules"?
Thanks!!
Regards
Implement org.kie.api.event.kiebase.KieBaseEventListener
, and in method afterRuleRemoved
count the events:
class MyKieBaseEventListener implements KieBaseEventListener {
private int removedRules;
public void afterRuleRemoved(AfterRuleRemovedEvent event){
removedRules++;
}
public int getRemovedRules(){
return removedRules;
}
// other methods
}
You have to attach this listener to the KieBase.
kieBase.addEventListener( new MyKieBaseEventListener() );