Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Defining Event Listeners | How the correlator executes event listeners | How the correlator evaluates event expressions
How the correlator evaluates event expressions
When the correlator processes an injection request, it executes the monitor's onload() statement, which typically defines an event listener. To understand how the correlator evaluates the event expression in the event listener, consider the following on statement:
on A()->B() and C()->D() processOrder();
The event expression consists of four templates and three operators. The operators are:
The correlator does not evaluate the right operand of a followed by operator until after its left operand has evaluated to true. Hence, B and D are not evaluated initially but will only be evaluated after A and C, respectively, have become true. Initially, the correlator evaluates the A and C event templates.
Suppose a C event arrives first. The C part of the event expression is now true and the correlator now evaluates the A and D event templates. Now suppose an A event arrives next. The correlator evaluates the B and D event templates. When a B event arrives the first term, A()->B(), of the event expression becomes true. Finally a D event arrives and the second term, B()->D() becomes true and so the expression as a whole evaluates to true. The event listener triggers.
As mentioned before, when the correlator instantiates an event listener each event template in the event listener is initially false. An event template changes to true when the correlator finds a matching event. In a given context, the correlator cannot find a matching event while it is setting up an event listener because the correlator processes only one thing at a time in each context. Everything happens in order and no two things happen simultaneously in a given context.
Of course, events are always coming into the correlator. These events go on the input queue of each public context to wait their turn for processing. So while a matching event might arrive while the correlator is setting up an event listener, as far as correlator processing is concerned, the event arrives later. See Understanding time in the correlator.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.