Drools为会话的列表输入中的每个项触发一条规则
我正在使用决策表,希望每个输入项触发一条规则 我正在使用decision,我已将Sequential=true设置为true,并将所有规则定义为同一激活组的一部分 当我触发drools规则引擎时,它只对第一个输入项求值,其他项被忽略。我想要的行为是每个输入项最多评估一条规则(由显著性定义的规则顺序) 我可以通过一次向会话发送一个项目来实现这一点,但我更愿意一次执行所有项目Drools为会话的列表输入中的每个项触发一条规则,drools,Drools,我正在使用决策表,希望每个输入项触发一条规则 我正在使用decision,我已将Sequential=true设置为true,并将所有规则定义为同一激活组的一部分 当我触发drools规则引擎时,它只对第一个输入项求值,其他项被忽略。我想要的行为是每个输入项最多评估一条规则(由显著性定义的规则顺序) 我可以通过一次向会话发送一个项目来实现这一点,但我更愿意一次执行所有项目 我使用的是Drools verison 6.5.0.FINAL和Java 7。Drools中没有现成的支持,无法实现您想要实
我使用的是Drools verison 6.5.0.FINAL和Java 7。Drools中没有现成的支持,无法实现您想要实现的目标。如果希望对每个事实对规则进行一次评估,则需要自己编写代码 一种方法可以是在处理一个输入时标记另一种类型的事实:
declare Marker
fact : Object
end
//Bellow are the rules that should be coming from your decision table.
//Each rule will do whatever it needs to do, and then it will create a
//Marker fact for the fact that was processed.
//These rules now include a "not" Conditional Element to avoid a fact to be
//evaluated more than once.
rule "Rule 1"
salience 100
when
$fact: Object(...) //your conditions
not Marker(fact == $fact)
then
//... Your logic
insert(new Marker($fact));
end
...
rule "Rule 50"
salience 50
when
$fact: Object(...) //your conditions
not Marker(fact == $fact)
then
//... Your logic
insert(new Marker($fact));
end
希望能有所帮助,感谢您的回复。我现在倾向于开发一个定制解决方案,因为我面临另一个与permgen有关的drools()问题。要配置简单的规则,似乎要做的工作太多了。
declare Marker
fact : Object
end
//Bellow are the rules that should be coming from your decision table.
//Each rule will do whatever it needs to do, and then it will create a
//Marker fact for the fact that was processed.
//These rules now include a "not" Conditional Element to avoid a fact to be
//evaluated more than once.
rule "Rule 1"
salience 100
when
$fact: Object(...) //your conditions
not Marker(fact == $fact)
then
//... Your logic
insert(new Marker($fact));
end
...
rule "Rule 50"
salience 50
when
$fact: Object(...) //your conditions
not Marker(fact == $fact)
then
//... Your logic
insert(new Marker($fact));
end