Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Defining Event Listeners : Defining event listeners with temporal constraints : Waiting within an event listener
Waiting within an event listener
The second timer operator available for use within event expressions is wait(float).
The wait operator lets you insert a ‘temporal pause' within an event expression. Once activated, a wait expression becomes true automatically once the specified amount of time passes. For example:
on A() -> wait(10.0) -> C() success();
Execution of this event listener proceeds as follows:
1. Set up an event template to watch for an A event.
2. After detecting an A event, wait 10 seconds.Set up an event template to watch for a C event.
In addition to being part of an event expression, wait can also be used on its own.
on wait(20.0) success();
When the correlator instaniates this event listener the event listener just waits for the number of seconds specified (here being 20), then it evaluates to true, triggers, and causes the correlator to execute the success() action.
Therefore a wait clause starts off being false, and then turns to true once its time period expires. This behavior can be inverted through use of not. The expression not wait (20.0) would start off being true, and stay true for 20 seconds before becoming false.
Consider the following example:
on B() and not wait(20.0) success();
This event listener triggers only if a B event is detected within 20 seconds after the correlator sets up the event template that watches for B events. After 20 seconds, the not wait(20.0) clause would become false and prevent the event listener from ever triggering. This would therefore be the same as
on B within(20.0) success();
By using all with wait, you can easily implement a periodic repeating timer,
on all wait(5.0) success();
This event listener triggers every 5 seconds and causes the correlator to execute the success() action each time.
See also Specifying 'and not' logic to detect when events are missing.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback