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
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.