Drools规则执行顺序(二)
程序员文章站
2022-05-28 11:17:05
...
当规则空间中的事实(fact)有多个时,规则会匹配多个组合.
测试结果
Rule rule = new Rule();
rule.setRuleName("test");
rule.setSalience(100);
ksession.insert(rule);
ksession.fireAllRules();
import test.Rule;
rule "test second"
salience 20
activation-group "test"
no-loop true
when
$test: Rule(ruleName matches "test", salience >= 110)
then
System.out.println($test + " the 1st");
end
rule "test first"
salience 10
no-loop true
when
$test: Rule( )
$show : String( )
then
System.out.println($test + " the 2nd");
System.out.println($show + " the 2nd");
end
rule "test three"
salience -10
activation-group "test"
no-loop true
when
$test: Rule( )
then
System.out.println($test + " the 3rd");
$test.setNo_loop(true);
Rule temp = new Rule();
temp.setRuleName("test");
temp.setSalience(110);
insert("show");
insert("test");
insert(temp);
end
测试结果
[email protected] the 3rd
[email protected] the 1st
[email protected] the 2nd
test the 2nd
[email protected] the 2nd
show the 2nd
[email protected] the 2nd
test the 2nd
[email protected] the 2nd
show the 2nd
下一篇: 插件化中加载so库解决方案
推荐阅读
-
drools规则引擎与kie-wb和kie-server远程执行规则(7.18.0.Final)
-
士兵队列训练问题:某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的
-
Netty4.0学习笔记系列之二:Handler的执行顺序
-
用二叉树的中序遍历来看Oracle执行计划的执行顺序
-
执行计划顺序不符合一般规则
-
Drools规则执行顺序(二)
-
Drools记录执行的规则
-
Drools规则执行顺序
-
Netty4.0学习笔记系列之二:Handler的执行顺序
-
drools规则引擎与kie-wb和kie-server远程执行规则(7.18.0.Final)