Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Defining Monitors | Communication among monitor instances | Using events to control processing
Using events to control processing
In addition to using events to share data, you can use events to control processing. Control events are like switches. You use them to move a monitor from one state to another. Control events typically contain little or no data; that is, they have one or no fields.
A common use for control events is to initialize or terminate a process. For example, rather than use an onload() statement to set things up, it is good practice to use a monitor's onload() statement to create an event listener for a start event. This practice defers initialization until the start event is received. Similarly, you can use a stop event to signal to a monitor that it should perform shutdown actions such as deallocating resources before you terminate the correlator.
For example, consider the following action:
action initialize() {
   on EndAuction() and not BeginAuction() startNormalProcessing();
   on BeginAuction() and not EndAuction() startAuctionProcessing();
   route RequestAuctionState(); //A service monitor will respond with
                                //an EndAuction or BeginAuction event
In this code, EndAuction and BeginAuction can be viewed as control events. Receipt of one of these events determines whether the monitor executes the logic associated with being in an auction or out of an auction.

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.