简体   繁体   中英

wso2 cep externalTime issue

According to User Guide I suppose that externalTime window (timestamp,time value) should keep events only in range:from timestamp to timestamp + time value.

For example, in execution plan

from input
select time:timestampInMilliseconds(time:dateAdd("2016-11-14 19:40:00", 5, 'minute',"yyyy-MM-dd HH:mm:ss"),'yyyy-MM-dd HH:mm:ss') as tm
insert into tmp;
from tmp#window.externalTime(tm,10 min)
select .....

I supposed that time frame is limited from 2016-11-14 19:45:00 till 2016-11-14 19:55:00.

But in fact events after 19:55 are fired in the publisher too.

Is it a bug ?

If no, how can I make a window from exact time ?

It is not a bug. I think you have misunderstood the usage of externalTime window. ExternalTime window is not a fixed time window, it's a sliding time window similar to the time window. However, the difference between the time window and the externalTime window is that it uses a timestamp attribute (the external timestamp) which is defined in the stream definition rather using actual event received time (the system time when the event arrived at the window) to decide the window for that particular event. And it becomes useful in situations where you want to replay an event stream, or if the actual event generation time is different from it's receiving time (due to high network latencies), etc..

AFAIU, if you only interested in events that arrived between 2016-11-14 19:45:00 and 2016-11-14 19:55:00 (a fixed time range), you can simply use a filter for that. refer to sample below; Otherwise, you might have to write your own extension for that purpose ( guide on writing custom extensions ).

from input
select time:timestampInMilliseconds() tm
insert into tmpStream;

-- 5 * 60 * 1000 Milliseconds = 5 min
from tmpStream[tm - time:timestampInMilliseconds('2016-11-14 19:45:00.000') >= 5 * 60 * 1000] 
select *
insert into withInTimeStream;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM