Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Defining Event Listeners : Listening for events that do not match
Listening for events that do not match
Sometimes it is useful to catch events that do not match other event templates. To do this, specify the unmatched keyword in an event template. An unmatched event template matches against events for which both of the following are true:
*Except for completed and unmatched event templates, the event does not cause any other event expression in the same context as the unmatched event template to match. For information about completed event templates, see the next topic.
*The event matches the unmatched event template.
The correlator processes an event as follows:
1. The correlator tests the event against all normal event templates. Normal event templates do not specify the completed or unmatched keyword.
2. If the correlator does not find a match, the correlator tests the event against all event templates that specify the unmatched keyword. If the correlator finds one or more matches, the matching event templates now evaluate to true. That is, if there are multiple unmatched event templates that match the event, they all evaluate to true.
The scope of an unmatched event template is the context that contains it. Suppose an event goes to two contexts. In one context, there is a matching event listener and in the other context there is a match against an unmatched event template. Both matches trigger the listener actions.
Specify the unmatched keyword with care. Be sure to communicate with other developers. If your code relies on an unmatched event template, and someone else injects a monitor that happens to match some events that you expected to match your unmatched event template, you will not get the results you expect.
A typical use of the unmatched keyword is to spawn a monitor instance to process a particular subset of events. For example:
event Tick{ string stock; ... }
monitor TiickProcessor {
   Tick tick;
   ...
   action onload() {
      on all unmatched Tick():tick spawn processTick();
   }
   action processTick() {
      on all Tick( stock=tick.stock ) ...;
   }
   ...
}
See also:
*Example using unmatched and completed.
*Writing echo monitors for debugging
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback