Apama Documentation : Developing Apama Applications : Developing Apama Applications in Java : Defining Event Expressions : Defining advanced event expressions : Specifying a perpetual listener for repeated matching
Specifying a perpetual listener for repeated matching
So far all the examples given have created listeners that will trigger on the first occurrence of an event (or sequence of events) that satisfies the supplied event expression.
For example,
public void onLoad() {
   EventExpression eventExpr = new EventExpression("Tick(*, >10.0)");
   eventExpr.addMatchListener(this);
}
locates the first occurrence of a Tick event that satisfies the Tick(*, >10.0) event template. This first suitable event triggers the listener and calls the match method of the registered match listener object.
However, you might want to detect all Tick events that satisfy the above event template (or event expression). To do this you must create a perpetual listener, that is, one that does not terminate on the first suitable occurrence, but instead stays alive and triggers repeatedly on every subsequent occurrence.
This effect can be achieved through use of the all event expression operator.
If the above is rewritten as follows,
public void onLoad() {
   EventExpression eventExpr =
     new EventExpression("all Tick(*, >10.0)");
   eventExpr.addMatchListener(this);
}
the listener created will now seek the first Tick event whose price is greater than 10. Upon detecting such an event it will trigger and call the match method. It will then return to monitoring the incoming event streams to look for the next suitable occurrence. This behavior will be repeated indefinitely until the listener is explicitly deactivated. This means that potentially the match method could be invoked multiple times.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback