规则
package com.rules
import entity.Ping
declare Ping
@role(event) // 要把插入的数据声明为event,默认是fact,
@expires(20s) // 用来显示设置事件的过期时间,也就是说过了这个时间,该事件就会从会话中移除,不能再使用
end
rule "testComplexEvent1"
duration 1000
when
// eval(true)
$p:Ping() over window:time(3s)
then
System.out.println("rule thread id:"+Thread.currentThread().getId()+"---age---"+$p.getCount());
end
测试类
@Test
public void duration1() throws Exception{
KieServices kss = KieServices.Factory.get();
KieContainer kc = kss.getKieClasspathContainer();
KieSession ks =kc.newKieSession("tes