Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Defining Event Listeners | Specifying and/or/not logic in event listeners | Specifying 'and not' logic to terminate event listeners | Pausing event listeners
Pausing event listeners
You can also specify and not when you want to listen for a pattern, pause when a particular condition occurs, and resume listening for that pattern when some other condition occurs. Consider the example that terminates the event listener after the market closes. Suppose instead that you want to listen for increases in stock prices only when there is no auction. When the correlator receives an InAuction event, you want to pause the event listener and when the correlator receives an AuctionClosed event you want the event listener to become active again. To do this, you can write something like the following:
action initialize() {
   on EndAuction() and not BeginAuction() notInAuctionLogic();
   on BeginAuction() and not EndAuction() inAuctionLogic();
   route RequestAuctionPhase();
action inAuctionLogic() {
   on EndAuction() notInAuctionLogic();
action notInAuctionLogic() {
   on all Price("IBM",>targetPrice) as p and not BeginAuction()
   on BeginAuction() inAuctionLogic();
The initialize() action sets up two event listeners that determine whether to start with the inAuctionLogic() action or the notInAuctionLogic() action. The response to the routed RequestAuctionPhase event is an EndAuction event or a BeginAuction event. As soon as one of these events arrive, both event listeners terminate. For example, if an EndAuction event arrives, the first event listener terminates because its EndAuction() event template evaluates to true and its not BeginAuction() event template also evaluates to true. The second event listener terminates because its not EndAuction() event template evaluates to false and so the event expression can never evaluate to true.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.