# Redundant State Subcription

**URL:** <https://forum.inductiveautomation.com/t/redundant-state-subcription/11813>\
**Category:** Module Development\
**Created:** [June 15, 2016, 4:29pm UTC](https://forum.inductiveautomation.com/t/redundant-state-subcription/11813 "2016-06-15T16:29:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaopmrod2](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@joaopmrod2](https://forum.inductiveautomation.com/u/joaopmrod2)\
**Post date:** [June 15, 2016, 4:29pm UTC](https://forum.inductiveautomation.com/t/redundant-state-subcription/11813/1 "2016-06-15T16:29:49Z")

</div>

How can I subscribe the gateway Redundant State? I am developing new OPC Drivers Modules and I need to know what is teh state of the system it is running on.

Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 15, 2016, 5:16pm UTC](https://forum.inductiveautomation.com/t/redundant-state-subcription/11813/2 "2016-06-15T17:16:01Z")

</div>

You can get the platform RedundancyManager via the GatewayContext, which should be accessible from the DriverContext your driver has:

```auto
RedundancyManager redundancyManager = driverContext.getGatewayContext().getRedundancyManager();
```

From there, you can add a RedundancyStateListener:

```auto
redundancyManager.addRedundancyStateListener(new RedundancyStateListener() {
	@Override
	public void redundancyStateChanged(RedundancyState newState) {
		// TODO
	}

	@Override
	public void redundancyConnStatusChanged(ClusterPeerConnectionStatus status) {
		// TODO
	}
});
```

You’ll likely be interested in the ActivityLevel that you can from the RedundancyState object.

---

<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:** [December 30, 2019, 5:58pm UTC](https://forum.inductiveautomation.com/t/redundant-state-subcription/11813/3 "2019-12-30T17:58:28Z")

</div>

We have realized we would like to monitor the redundancy state via a timer script and gateway tags. Is there a way to add this state listener right from a startup script?

I would rather not have to make a module just to monitor this status unless I absolutely have to.

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:** [December 30, 2019, 9:17pm UTC](https://forum.inductiveautomation.com/t/redundant-state-subcription/11813/4 "2019-12-30T21:17:24Z")

</div>

Just for posterity:

The following code on a gateway timer script will get the sync status of the redundant pair:  
Ennumerated values are defined here: [http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/com/inductiveautomation/ignition/gateway/redundancy/types/ProjectState.html](http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/com/inductiveautomation/ignition/gateway/redundancy/types/ProjectState.html)

```auto
from com.inductiveautomation.ignition.gateway import SRContext
contextRM = SRContext.get().getRedundancyManager()
state = contextRM.getPeerConnectionStatus().getProjectState().toString()
system.tag.write("[default]ReplicationState",state)

```
