Using ondie() to diagnose runtime errors
You cannot catch and handle runtime errors like you can handle exceptions in other languages. You cannot prevent the correlator from terminating the monitor instance. However, you can specify some logging in the ondie() action to help diagnose the problem and to alert other system modules that a problem occurred. For example:
action ondie() {
log "sub-monitor terminating for " + myId;
route InternalError("Foo");
}
In some circumstances, you can move into a suspended or safe state, or initiate damage limitation activities, for example, such as pulling all active orders from the market. For example, Apama scenarios use the ondie() action to route an InstanceDied() event to a ScenarioService monitor. This in turn sends the event to connected clients so the termination of the instance can be handled, perhaps displayed, in a dashboard)
An alternative to using ondie() in this manner is to use a basic ACK, NACK, and timeout message exchange protocol so that a client is robust against its services being unavailable.