Мы использовали 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