Apama Documentation : Developing Apama Applications : Developing Apama Applications in Java : Defining Event Expressions : Defining advanced event expressions : Specifying the timer operators : Waiting within a listener
Waiting within a listener
The second timer operator available for use within event expressions is wait(float).
wait allows you to insert a ‘temporal pause' within an event expression. Once activated, a wait expression becomes true automatically once a set amount of time passes. For example,
A -> wait(x seconds) -> C
will proceed as follows; activate the listener and look for the A event expression or template, then once A becomes true pause (i.e. wait) for x seconds, then finally start looking for the C event expression or template.
In addition to being part of an event expression, wait can also be used on its own,
wait(20.0)
is a valid event expression in its own right. When its listener activates it just waits for the number of seconds specified (here being 20), then it evaluates to true and calls any registered match methods.
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.
The following,
B and not wait(20.0)
is an interesting example. It effectively means that this listener will trigger only if a B occurs within 20 seconds of its activation. After that the not wait(20) clause would become false and prevent the listener from ever triggering.
By using all with wait, you can easily implement a periodic repeating timer,
all wait(5.0)
This listener will trigger every 5 seconds and calls any registered match methods.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback