0

我们已经建立了一个基本的Drools框架Guvnor UI。规则是由半技术人员编写的,并且存在错误范围(范围总是存在的,无论是谁编写的 :))

昨天,有人写了一个开始抛出的规则,NullPoiterException但 Drool 似乎将此异常包装到 CYCLIC_DEPENDENCY_ERROR 中并显示相同。

java.lang.OutOfMemoryError: Java heap space此外,我们在此问题后立即(3-4 分钟)结束了 OOM 。

堆栈跟踪以获取详细信息:

Feb 2013 08:06:55,447 [ERROR]  (SWF Activity  DroolsActivityTaskList-2.2 229) com.amazon.mobius.csi.workers.droolsengine.DroolsEngineActivitiesImpl:runRules:220 [CYCLIC_DEPENDENCY_ERROR]: Error
 while executing Rules, Please validate all rules against any cyclic dependency
Exception executing consequence for rule "final NON EC" in com.amazon.mobius.csi.workers.droolsengine: java.lang.NullPointerException
        at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
        at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
        at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
        at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
        at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:708)
        at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:672)
        at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
        at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:295)
        at com.amazon.mobius.csi.workers.droolsengine.DroolsEngineActivitiesImpl.runRules(DroolsEngineActivitiesImpl.java:216)
        at com.amazon.mobius.csi.workers.droolsengine.DroolsEngineActivitiesImpl.executeRules(DroolsEngineActivitiesImpl.java:145)
        at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementation.execute(POJOActivityImplementation.java:63)
        at com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationBase.execute(ActivityImplementationBase.java:46)
        at com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller.execute(SynchronousActivityTaskPoller.java:214)
        at com.amazonaws.services.simpleworkflow.flow.worker.ActivityTaskPoller$2.run(ActivityTaskPoller.java:95)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
        at com.amazon.mobius.csi.workers.droolsengine.Rule_final_NON_EC.defaultConsequence(Unknown Source)
        at com.amazon.mobius.csi.workers.droolsengine.Rule_final_NON_ECDefaultConsequenceInvoker.evaluate(Unknown Source)
        at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
        ... 18 more

为什么 Drools 将其视为 CYCLIC_DEPENDENCY 并导致 OOM?我们能有其他问题吗?任何帮助,将不胜感激。

谢谢,

4

1 回答 1

0

我相信这是规则之间的循环依赖。一个规则的 RHS 导致另一个规则激活,而后者又具有一个 RHS 导致第一个规则激活。因此存在无限循环的规则激活。

在没有看到规则本身的情况下,我建议设置一个议程事件侦听器来记录正在触发的规则。这样,您应该能够看到以这种方式激活的 2 个规则。此类日志记录侦听器的示例如下:

https://github.com/gratiartis/scattercode-drools-scenarios/blob/master/src/main/java/uk/co/scattercode/drools/util/TrackingAgendaEventListener.java

于 2013-03-22T13:45:07.770 回答