gpt4 book ai didi

java - Drools Execution,获取撤回数量

转载 作者:行者123 更新时间:2023-12-01 12:32:15 25 4
gpt4 key购买 nike

我正在尝试返回 drools session 执行的撤回次数。

我可以获得执行次数:

...
final Command fireAllRulesCmd = CommandFactory.newFireAllRules("executed-rules");
cmds.add(fireAllRulesCmd);
...
session.execute(CommandFactory.newBatchExecution(cmds));
final Integer executedRules = (Integer) execute.getValue("executed-rules");
....

是否有类似的方法来获取所有“retracted-rules”?

谢谢!!

问候

最佳答案

实现org.kie.api.event.kiebase.KieBaseEventListener,并在方法afterRuleRemoved中对事件进行计数:

class MyKieBaseEventListener implements KieBaseEventListener {
private int removedRules;
public void afterRuleRemoved(AfterRuleRemovedEvent event){
removedRules++;
}
public int getRemovedRules(){
return removedRules;
}
// other methods
}

您必须将此监听器附加到 KieBase。

kieBase.addEventListener( new MyKieBaseEventListener() );

关于java - Drools Execution,获取撤回数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25845932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com