Redundancy in module development

Hello everyone,

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?

Thanks!

1 Like

You need to use the Redundancy State Listener:

import com.inductiveautomation.ignition.gateway.redundancy.types.RedundancyState;
import com.inductiveautomation.ignition.gateway.redundancy.types.RedundancyStateListener;

code snippets:

   @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.

2 Likes

So among other things, I would need to startup my module once the redundancy kicks in and shut it down once the master is up again?

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.

1 Like

Got it, thanks!