My module has some tasks scheduled synchronously in the gateway (reading from tags, inserting calculations into a database, etc.) and some project resources. I was wondering what should I take into consideration to make the module redundancy-proof (if the master gateway fails, the module should work on the redundant gateway). ¿Does anyone have any experience/advice on this topic?
@Override
public void redundancyStateChanged(RedundancyState redundancyState) {
logger.debug("Redundancy State Changed to %s",redundancyState.getActivityLevel().toString());
if(redundancyState.getActivityLevel().equals(ActivityLevel.Active)){
this.isActive = true;
}
else{
this.isActive = false;
}
}
@Override
public void redundancyConnStatusChanged(ClusterPeerConnectionStatus clusterPeerConnectionStatus) {
}
EDIT: You have to implement the logic internally but these hooks let you know what state the Gateway is in. This works well for my SNMP Driver that I wrote.
In addition to the RedundancyStateListener described by @brandon1, you may also want to register a RuntimeStateProvider with the context’s RuntimeStateManager. This is the tool that facilitates regularly moving current state from the active to the inactive peer, minimizing the bump on failover.