Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Using Correlator Persistence : Sample code for persistence applications : Sample code that recovers subscription to non-persistent monitor
Sample code that recovers subscription to non-persistent monitor
This sample code defines a persistent monitor that subscribes to a non-persistent service monitor. Note that the service monitor can handle the case where the subscription is received before the adapter is connected.
monitor service_monitor {
action onload() {
Subscribe s;
on all Subscribe():s {
if not connected then {
pendingSubscribes.append(s);
} else {
if(incrRefCount(s.subkey) then {
send Adapter_Subscribe(s.subkey) to "output";
}
}
}
on all wait(1.0) {
send IsAdapterUp() to "output";
}
on all AdapterUp() {
connected:=true;
for s in pendingSubsscribes {
route s;
}
pendingSubscribes.clear();
}
}
}

persistent monitor eg2 {
listener l;
Instance i;
context svcCtx;
action spawnedInstance(context c) {
svcCtx:=c; // Contains anything required to recover subscription.
send Subscribe(i.subkey) to svcCtx;
Data d;
l:=on all Data():d { process(d); }
}
action onConcludeRecovery() {
// Non-persistent service monitor is now reset to its onload state.
// Re-subscribe.
send Subscribe(i.subkey) to svcCtx;
}
}
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback