Pcgomes
Pcgomes

Reputation: 302

Esper EPL - Differentiate deleted events from released events in a timed window

I count events within a timed window. If more than 5 events arrive at that window, then I want to discard them all. Otherwise, the events are released after the waiting time.

My code goes something like this:

// Create a timed window of 10 seconds
create window MyWindow.win:time(10 sec) as MyEventType;

// Add to the timed window
insert into MyWindow select * from MyEventType;

//Delete from window if upper limit was reached
On MyEventType as newEvent 
   select and delete * from MyWindow as oldEvent
   having COUNT(*) >= 5;

Additionally, a listener receives all events that leave the timed window:

select rstream * from MyWindow;

The problem with the example above is that both deleted and released events are forwarded to the listener (via rstream).

Question: how to differentiate deleted events from released ones?

Upvotes: 1

Views: 88

Answers (1)

user650839
user650839

Reputation: 2594

There is nothing on the events afaik. I think an application could look at the time of the event and see if its older than current time. I can think of another option whereas a listener of on-delete receives the deleted events and not the expired ones which given the application a means to know what was deleted and what was expired.

Upvotes: 1

Related Questions