# Redundancy in module development

**URL:** <https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525>\
**Category:** Module Development\
**Tags:** ignition80, ignition81\
**Created:** [November 29, 2021, 2:33pm UTC](https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525 "2021-11-29T14:33:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlunapinel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mlunapinel/32/19719_2.png) [@mlunapinel](https://forum.inductiveautomation.com/u/mlunapinel)\
**Post date:** [November 29, 2021, 2:33pm UTC](https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525/1 "2021-11-29T14:33:06Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [November 29, 2021, 3:29pm UTC](https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525/2 "2021-11-29T15:29:29Z")

</div>

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:

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

---

<div class="post-metadata">

**Author:** ![mlunapinel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mlunapinel/32/19719_2.png) [@mlunapinel](https://forum.inductiveautomation.com/u/mlunapinel)\
**Post date:** [November 29, 2021, 3:46pm UTC](https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525/3 "2021-11-29T15:46:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 29, 2021, 3:48pm UTC](https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525/4 "2021-11-29T15:48:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mlunapinel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mlunapinel/32/19719_2.png) [@mlunapinel](https://forum.inductiveautomation.com/u/mlunapinel)\
**Post date:** [November 29, 2021, 3:49pm UTC](https://forum.inductiveautomation.com/t/redundancy-in-module-development/53525/5 "2021-11-29T15:49:10Z")

</div>

Got it, thanks!
