我们已经使用Drools 7.7编写规则。我们正在尝试编写多个规则,在每个规则中我们都在使用更新的事实,并尝试在下一个规则条件下使用更新的事实,但是流口水却抛出了异常。
我们正在以连续模式运行流口水。具有以下配置:-
kieSessionBuilder.setKieBaseMap(
ruleGroupId, kieHelper.build(SequentialAgendaOption.DYNAMIC, SequentialOption.YES));
Rule 1
Salience "1"
no-loop
when
$allocatedQuantity : AllocatedQuantity(receivedQuantity<allocatedQuantity)
$inventory : Inventory (location == 'A')
then
$allocatedQuantity.setReceivedQuantity($allocatedQuantity.getReceivedQuantity()+ $inventory.getQuantity());
update($allocatedQuantity);
end
Rule 2
Salience "2"
no-loop
when
$allocatedQuantity : AllocatedQuantity(receivedQuantity<allocatedQuantity)
$inventory : Inventory (location == 'B')
then
$allocatedQuantity.setReceivedQuantity($allocatedQuantity.getReceivedQuantity()+ $inventory.getQuantity());
update($allocatedQuantity);
end
Rule 3
Salience "3"
no-loop
when
$allocatedQuantity : AllocatedQuantity(receivedQuantity<allocatedQuantity)
$inventory : Inventory (location == 'C')
then
$allocatedQuantity.setReceivedQuantity($allocatedQuantity.getReceivedQuantity()+ $inventory.getQuantity());
update($allocatedQuantity);
end
Rule 4
Salience "4"
no-loop
when
$allocatedQuantity : AllocatedQuantity(receivedQuantity<allocatedQuantity)
$inventory : Inventory (location == 'D')
then
$allocatedQuantity.setReceivedQuantity($allocatedQuantity.getReceivedQuantity()+ $inventory.getQuantity());
update($allocatedQuantity);
end
Rule 5
Salience "5"
no-loop
when
$allocatedQuantity : AllocatedQuantity(receivedQuantity<allocatedQuantity)
$inventory : Inventory (location == 'E')
then
$allocatedQuantity.setReceivedQuantity($allocatedQuantity.getReceivedQuantity()+ $inventory.getQuantity());
update($allocatedQuantity);
end
执行第4条规则,但在第5条规则中,它抛出以下异常:-
java.lang.NullPointerException: null
at org.drools.core.phreak.PhreakFromNode.doLeftUpdates(PhreakFromNode.java:181) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.PhreakFromNode.doNode(PhreakFromNode.java:64) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:387) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:333) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.doRiaNode(RuleNetworkEvaluator.java:606) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:533) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:373) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:333) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:169) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:127) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:212) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:87) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1067) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1014) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1006) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1308) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1299) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1283) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:281) ~[drools-core-7.7.0.Final.jar:7.7.0.Final]
at