WSO2 CEP:Siddhi QL:如何在匹配特定条件后一致地警告事件

WSO2 CEP:Siddhi QL:如何在匹配特定条件后一致地警告事件,wso2,complex-event-processing,wso2cep,siddhi,Wso2,Complex Event Processing,Wso2cep,Siddhi,从下面的流程中,我想提醒温度超过90时发生两次的事件(就像每两个温度>90的事件都需要提醒一样) 我写过这样的东西: @Plan:name('TestExecutionPlan') define stream InputStream (id string, temp int); partition with (id of InputStream) begin from InputStream select id, temp having temp > 90 insert into

从下面的流程中,我想提醒温度超过90时发生两次的事件(就像每两个温度>90的事件都需要提醒一样)

我写过这样的东西:

@Plan:name('TestExecutionPlan')

define stream InputStream (id string, temp int);

partition with (id of InputStream)
begin
from InputStream
select id, temp
having temp > 90  
insert into CriticalStream
end;

from CriticalStream[count(id) == 2]
select id, temp
group by id
--having count(id) == 2
insert into EventReporter;
但是,它只会在EventReporter流中提醒1个事件


我希望EventReporter流也有[1001,97]和[1001,98],现在它只有[1001,95]的记录。有人能指出我做错了什么吗。如何在对事件进行分组后循环事件?我尝试添加window.time和window.length,但没有得到所需的输出。如有任何帮助/指导,将不胜感激。谢谢。

您不需要在那里设置分区。您只需使用过滤器和lengthBatch窗口即可获得所需的输出。试试下面的执行计划

@Plan:name('ExecutionPlan')

@Import('InputStream:1.0.0')
define stream InputStream (id string, temp int);

/* Filter events with temp > 90 */
from InputStream[temp > 90]
insert into CriticalStream;

/* Aggregate within a lengthBatch window, while group by id*/
from CriticalStream#window.lengthBatch(2)
select id, temp, count() as count
group by id
insert into EventReporter;

/* Just for logging the result in the cosole */
from EventReporter#log("Logging EventReporter : ")
insert into #temp;

嗨,Grainier,这个解决方案奏效了。非常感谢您的时间和帮助。Grainier,我还有一个问题:非常感谢您能看一看并给出宝贵的意见。非常感谢。
@Plan:name('ExecutionPlan')

@Import('InputStream:1.0.0')
define stream InputStream (id string, temp int);

/* Filter events with temp > 90 */
from InputStream[temp > 90]
insert into CriticalStream;

/* Aggregate within a lengthBatch window, while group by id*/
from CriticalStream#window.lengthBatch(2)
select id, temp, count() as count
group by id
insert into EventReporter;

/* Just for logging the result in the cosole */
from EventReporter#log("Logging EventReporter : ")
insert into #temp;