WSO2 CEP:Siddhi QL:如何在匹配某些条件后始终如一地警告事件

时间:2017-04-05 09:25:15

标签: wso2 complex-event-processing wso2cep siddhi

从下面的流中,我想提醒当温度超过90时发生过两次的事件(比如需要提醒temp> 90的每2个事件)。

InputStream=[1001,91]
InputStream=[1001,86]
InputStream=[1002,70]
InputStream=[1001,85]
InputStream=[1003,70]
InputStream=[1003,85]
InputStream=[1002,70]
InputStream=[1003,70]
InputStream=[1003,87]
InputStream=[1002,70]
InputStream=[1001,95]
InputStream=[1001,96]
InputStream=[1001,97]
InputStream=[1001,98]
InputStream=[1001,98]

我写过这样的话:

@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个事件。

Below is the screen shot from Try It

我期待EventReporter流也有[1001,97]和[1001,98],现在它只有[1001,95]的记录。有人可以指出我在这里做错了什么。如何在分组之后循环播放事件?我尝试添加window.time和window.length,但没有得到所需的输出。任何帮助/指导将非常感激。谢谢。

1 个答案:

答案 0 :(得分:1)

你不会在那里要求分区。您只需使用过滤器和lengthBatch窗口即可获得所需的输出。尝试以下执行计划;

{
    "_id" : "AS6D0",
    "invoiceNumber" : 23,
    "bookingId" : "AS6D0",
    "createDate" : 1490369414,
    "dueDate" : 1490369414,
    "invoiceLines" : [ 
        {
            "lineText" : "Rent Price",
            "amountPcs" : "8 x 7500",
            "amountTotal" : 60000
        }, 
        {
            "lineText" : "Discount(TIKO10)",
            "amountPcs" : "10%",
            "amountTotal" : -10000
        }, 
        {
            "lineText" : "Final cleaning",
            "amountPcs" : "1 x 5000",
            "amountTotal" : 5000
        }, 
        {
            "lineText" : "Reservation fee paid already",
            "amountPcs" : "1 x -20000",
            "amountTotal" : -20000
        }
    ],
    "managerId" : "4M4KE"
}