Search code examples
real-timedistributed-computingespercomplex-event-processing

Registering triggers for missing expected events using Esper in real-time


My use-case is to identify entities from which expected events have not been received after X amount of time in real-time rather than using batch jobs. For Example:

If we have received PaymentInitiated event at time T but didn't receive either of PaymentFailed / PaymentAborted / PaymentSucedded by T+X, then raise a trigger saying PaymentStuck along with details of PaymentIntitiated event.

1. Can I capture such triggers using Esper?

In my actual use-case X is not constant and varies as per each record which I would know before the first event has occured.

2. Can Esper support registering such dynamic queries where X is not constant?

Thanks, Harish


Solution

  • You could use a pattern such as "pattern [every pi=PaymentInitiated -> timer:interval(pi.amountOfTimeInSeconds) and not (PaymentAborted(id=pi.id) or PaymentStuck(id=p.id))]" An outer join is also handy to detect absences. The solution patterns page in among the Esper web site has more examples.