我想建立一个简单的监视器。谁在时间窗口中侦听事件并执行侦听器。但是监听器没有被执行。我感觉 Apama 引擎不支持这一点。
来自文档:临时操作是 CEP 的常见要求。例如,我们可能想对我们的表达设置时间限制。within 运算符指定表达式必须完成的时间(以秒为单位),从第一次激活组成模板时开始。当我们在 15.0 秒内同时收到带有相应字段的 MyEvent 和 MyOtherEvent 时,下面的表达式就完成了。为了澄清,在这个表达式中,计时器在 MyEvent 或 MyOtherEvent 匹配时启动:
on all MyEvent(id="important") and MyOtherEvent(id="important") within 15.0
//Eventdefinition
&FLUSHING(1)
&SETTIME("2019-04-03T14:07:00.0+01:00")
&TIME("2019-04-03T14:07:01.0+01:00") // sec 1
TestEvent("START","1")
&TIME("2019-04-03T14:07:02.0+01:00") // sec 2
TestEvent("BODY_ID","1")
&TIME("2019-04-03T14:07:03.0+01:00") // sec 3
TestEvent("BODY_TYPE","1")
&TIME("2019-04-03T14:07:20.0+01:00") // sec 4
TestEvent("BODY_MODELL","1")
//EPL monitor Rule
on all TestEvent(tag= "BODY_ID") as test
and TestEvent(tag = "START") as test1 within(5.0)
{
log "test" + test.tag at INFO; //never called!
}
- - -编辑 - - -
另一种解决方案是这个,但不漂亮!而且您无法访问事件的详细信息。
on all (
TestEvent(tag = "START") as e1
or TestEvent(tag= "BODY_ID") as e2
or TestEvent(tag= "BODY_TYPE") as e3
or TestEvent(tag= "BODY_MODELL") as e4
) -> (//followd by random tag
TestEvent(tag = "START")
or TestEvent(tag = "BODY_ID")
or TestEvent(tag = "BODY_TYPE")
or TestEvent(tag = "BODY_MODELL")
) within(3.0) -> (//followd by random tag
TestEvent(tag = "START")
or TestEvent(tag = "BODY_ID")
or TestEvent(tag = "BODY_TYPE")
or TestEvent(tag = "BODY_MODELL")
) within(3.0) -> (//followd by random tag
TestEvent(tag = "START")
or TestEvent(tag = "BODY_ID")
or TestEvent(tag = "BODY_TYPE")
or TestEvent(tag = "BODY_MODELL")
) within(3.0) {
//Problem: No e1, e2,e3,e4 are not accessible...
}