Search code examples
complex-event-processingesperepl

Simple sequence of events


Assume events of either type A, B, C or D are being emitted. I want to detect whenever an event of type A is followed by an event of type B. In other words, I want to detect a sequences, for which Esper's EPL provides the -> operator.

However, what I described above is ambiguous, what I want is the following: Whenever a B is detected, I want it to be matched with the most recent A.

I have been playing around with EPL's syntax, but the best I could come up with was that:

select * from pattern [(every a=A) -> b=B]

This, however, matches each B with the oldest A that occured after the last match. Weird...

Help is much appreciated! :P


Solution

  • I use joins a lot for the simple matching. The other option is match-recognize. The join like this.

    select * from B unidirectional, A.std:lastevent()