Drools规则执行顺序

以堆栈方式执行,优先级低的先入栈,同一优先级的,在规则文件中位置靠前的先入栈.
测试1
rule "test first"
salience 0
no-loop false
when
$test: String( )
then
System.out.println($test);
insert("test second");
end

rule "test second"
salience -10
when
$test: String( )
then
System.out.println($test + " the 2nd");
insert("test three");
end

测试1结果
test
test second
test second the 2nd
test three
test three the 2nd
test the 2nd

测试2
rule "test first"
salience 0
no-loop false
when
$test: String( )
then
System.out.println($test);
insert("test second");
end

rule "test second"
salience 0
no-loop false
when
$test: String( )
then
System.out.println($test + " the 2nd");
insert("test three");
end

测试2结果
test the 2nd
test three the 2nd
test three
test second the 2nd
test second
test

同一互斥组下,优先级高的如果no-loop true,则,此规则内如果插入新对象,视本规则为不匹配,执行下一规则.
测试3
rule "test second"
salience 0
activation-group "show"
no-loop true
when
$test: String( )
then
System.out.println($test);
insert("test second");
end

rule "test first"
salience 0
activation-group "show"
no-loop true
when
$test: String( )
then
System.out.println($test + " the 2nd");
insert("test three");
end

测试3结果
test the 2nd
test three
test second the 2nd
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值