Apama 10.7.2 | Developing Apama Applications | Developing Apama Applications in EPL | Defining Event Listeners | How the correlator executes event listeners | Avoiding event listeners that trigger upon instantiation
 
Avoiding event listeners that trigger upon instantiation
Because all event templates are initially false, it is important to think carefully before specifying not in an event expression. It is easy to inadvertently specify the not operator in such a way that the expression evaluates to true immediately upon instantiation. Since this triggers the specified action without any events occurring, it is unlikely to be what you intended and you want to avoid doing this. Consider the following example:
on ( A() -> B() ) or not C() myAction();
Assuming that A, B and C represent event templates, the value of each starts as being false. This means that not C is immediately true, and hence the whole expression is immediately true, which triggers the specified action. If any of A, B or C is a nested event expression the same logic applies for its evaluation. Typically, the not operator is used in conjunction with the and operator. See Choosing which action to execute.
When an event listener triggers the correlator sends a request to the front of the context's input queue to execute the event listener action. For example:
route D();
on not E() {
   print "not E";
}
route F();
The route keyword sends the specified event to the front of the context's input queue. The correlator processes this code in the following order:
1. The correlator processes event D.
2. The correlator prints "not E".
3. The correlator processes event F.