Search code examples
javacomplex-event-processingesper

Esper time functions do not seem to work


EPL statements dealing with native time are not working in Esper. I am using version 5.3.0. I can't seem to get anything with time to perform right.

timer:within(1 sec)

I had issues with getting the timer to function. I have and statements appended to the EPL statement and the EPL statement function regardless of the timer:within(1 sec).


Solution

  • If you choose to control time yourself, you need to keep sending CurrentTimeEvent-s to "tell" Esper what time it is (Esper will not increment time for you at all. If you send an event to tell Esper it is today 10:00am, the time stays 10:00am until you send another CurrentTimeEvent event, it will not change as your program continues to run).

    If you use statements with "timer:within" and similar time based functionality, you may need to have a separate thread which keeps sending CurrentTimeEvent-s every xxx milliseconds/seconds to make these statements work as you would expect.

    In my experience, controlling time yourself is useful when you want to "replay" events. If you store events before they hit Esper, you can later replicate exactly what happened on a given day, by loading all events from your storage and sending them into Esper (with a CurrentTimeEvent event right before each actual event object).