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() {
on all Subscribe() as s {
if not connected {
pendingSubscribes.append(s);
} else {
if(incrRefCount(s.subkey) {
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;
l:=on all Data() as 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-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback