wso2 - How do I implement a continuous time window in CEP? -


say have stream of events , want able count how many of them there in time window. receive notification whenever event enters time window , changes count , same when event exits time window.

the below illustration show mean. i'm using time window of length 4 , want 3 notifications, 1 when first event enters window, second when second event enters , third when first event exits time window.

enter image description here

how make query that? if want group event's property?

here's have far, doesn't give me notification when event leaves window: @config(async = 'true') define stream mystream (symbol string, timestamp long) @info(name = 'query1') mystream#window.externaltime(timestamp,10 sec) select symbol, timestamp, count(timestamp) eventcount group symbol insert outputstream. siddhi cep, imagine esper similar.

from type of window in wso2 cep, can expect 2 types of events.

  1. current events - these triggered when new event enters window. i.e. new event used trigger
  2. expired events - these triggered when existing event in window exits it. i.e. in case of time window of 1 minute, each event kept 1 minute , emitted @ end of 1 minute

you can use combination of these 2 in same query trigger both types of events.

an example query uses both types of triggers in cep 3.1.0 (check docs here):

from stockexchangestream[symbol == 'wso2']#window.time( 1 minute )  select max(price) maxprice, avg(price) avgprice, min(price) minprice insert wso2stockquote all-events   

if want triggered using expired events, use 'expired-events' in place of 'all-events'. same applies current-events. if don't specify anything, defaults current-events, that's why current query doesn't triggered expired events.

note cep 4.0.0 syntax bit different, correct syntax check test source codes here (since docs still work-in-progress).


Comments