流口水-重复事件和时间关系 [英] Drools - Repeated Events and Temporal Relations

查看:64
本文介绍了流口水-重复事件和时间关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我正在为事件定义规则,这些事件等于(通过属性值)事件可以以连续的方式(每秒)发生。我只想按小时为匹配事件触发规则。

In general I am writing rules for events which equal (by attributes values) events can occur any time in consecutive manner (every second). I want to fire rules for matched events only on an hourly bases.

更多详细信息:
我想在为事件插入事件时触发规则第一次(尚不存在),或者当插入一个事件且仅当相等的事件已经插入到工作存储器中时,最新的事件至少早于一个小时前。

In more details: I want to fire a rule when an event is inserted for the first time (not exist yet) OR when an event is inserted and if and only if equal events are already inserted to the working memory BUT the newest of them is at least one hour ago old.

编写这种规则的合理方法是什么,参加事件的持续时间将为24H?

What is a reasonable way of writing a rule of that kind, taking events duration will be 24H?

推荐答案

rule X
when
    $e : MyEvent() from entry-point "s"
    not( MyEvent( this != $e, id == $e.id, this before[0s,1h] $e ) from entry-point "s" )
then
    // $e arrived and there is no other event with the same
    // id that happened during the last hour
end

替换 id == $ e .id,无论您决定两个事件使用什么约束,都是相互关联的。

Replace "id == $e.id" by whatever constraints you use to decide two events are related to each other.

这篇关于流口水-重复事件和时间关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆