rule "salience2"
salience 2
when
eval(true)
then
System.err.println("salience2");
end
rule "salience1"
salience 1
when
eval(true)
then
System.err.println("salience1");
end
1
2
3
4
@Test
public void testSalience() {
kieSession.fireAllRules();
}
2. date-effective日期比较(小于等于)
当系统时间小于等于date-effective的值是才会执行。
1
2
3
4
5
6
7
8
9
10
11
12
13
rule "dateEffective"
date-effective "2018-11-24"
when
then
System.err.println("2018-11-24被执行");
end
rule "dateEffectiveTomorrow"
date-effective "2018-11-25"
when
then
System.err.println("2018-11-25被执行");
end
1
2
3
4
5
6
7
8
9
@Test
public void testDateEffective() {
kieSession.fireAllRules(new RuleNameEndsWithAgendaFilter("dateEffective"));
}
@Test
public void testDateEffectiveTomorrow() {
kieSession.fireAllRules(new RuleNameEndsWithAgendaFilter("dateEffectiveTomorrow"));
}
rule "test1"
when
then
insert(new User("赵六",12));
System.err.println("创造赵六");
end
rule "test2"
when
$u:User(name=="赵六")
then
$u.setName("王五");
update($u);
System.err.println("赵六");
end
rule "test3"
when
$u:User(name=="王五")
then
System.err.println("王五");
retract($u);
end
rule "test4"
when
$u:User(name=="王五")
then
System.err.println("王五删除删除之后"+$u.getName());
end