Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Using Correlator Persistence | Sample code for persistence applications | Sample code for discarding stale state during recovery
Sample code for discarding stale state during recovery
The following code provides an example of discarding stale data during recovery. This application discards all recovered Data events because their data has become stale. However, the application always processes and does not discard ControlEvent events.
persistent monitor eg1 {
listener l;
listener lt;
action onload() {
on all ControlEvent() as c { handleControl(c); }
action initiateListeners() {
l:=on all Data() as d { process(d); } // Process is moderately expensive
lt:=on all wait(0.1) { send Average(state) to "output"; }
action onBeginRecovery() {
l.quit(); // Discard all recovered Data events.
lt.quit(); // Stop sending intermittent updates.
// Do not flood receivers.
// Note that the ControlEvent listener is still present.
// The code throttles only Data events. If the
// ControlEvent listener is not present, this monitor
// would have no listeners and would terminate
// after this action.
action onConcludeRecovery() {
initiateListeners(); // Go back to normal.

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.