首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

drools 规则引擎 over window:time(1d)的有关问题

2012-10-06 
drools 规则引擎 over window:time(1d)的问题drl文件中定义?package com.sampledeclare Activity@role( ev

drools 规则引擎 over window:time(1d)的问题

drl文件中定义

?

package com.sample


declare Activity
@role( event )
@timestamp(txTime)
end

?

rule "totaltimessrule"
salience 1
when
$account:Account($accountnumber:accountnumber) from entry-point ActivityStream
$totaltimes:Number(intValue >= 20)from accumulate(
$Activity:Activity() over window:time(1d) from entry-point ActivityStream, count($Activity))
then
System.out.println($accountnumber);
System.out.println(drools.getRule().getName());
end

?

然后在java代码中插入的Activity的txtime(规则引擎的时间戳)全为 2011-6-1

时钟采用realtime实时时钟,执行时间为2011-6-7

采用滑动窗口over window:time(1d)按说应该取自实时时钟2011-6-7当天数据作为活动窗口数据,也就是说没有数据,按说将不会触发该规则,为啥触发了呢,而且每次执行结果具有不确定性

when
    $now: CurrentTime() from entry-point "My Stream"
    //The following should fetch all events occurred in the last 2 seconds)
    $event: MyEvent(this before[2s, 2s] $now) from entry-point "My Stream"
then
    System.out.println($event.getEventName() + ": Event Occured!!!" +      $event.getEventDateTime().toString());
end

作为权宜之计

热点排行