About executing ondie() actions
A monitor instance can terminate for any of the following reasons:
It executes all its code and has no active listeners or streaming elements.
The
die() operation is called on it.
The
engine_delete utility or an Apama client API removes the monitor from the correlator.
A run-time error is detected in the monitor’s code, which causes that instance of the monitor to die.
In all of these situations, if the monitor defines an ondie() action, the correlator invokes it. Like the onload() and onunload() actions, ondie() is a special action because the correlator invokes it automatically in certain situations.
Suppose that a monitor that defines the ondie() action spawns ten times, and each monitor instance dies. The correlator invokes ondie() eleven times: once for each spawned monitor instance, and once for the initial monitor instance. Then, just before the monitor’s EPL is unloaded from the correlator, the correlator invokes the onunload()action only once, and it does so in the context of the last remaining monitor instance.
The correlator executes each ondie() operation in the context of its monitor instance. Therefore, the ondie() operation can access the variables in the monitor instance being terminated.
You cannot spawn in an ondie() or an onunload() action.