Spring Data Redis - 如何检测故障转移以重新订阅频道

Spring Data Redis - How to detect a failover to resubscribe to channels

我正在使用 Spring Data Redis 和 Redis Sentinel 并订阅键空间事件通知。 如何检测由于故障转移而切换到新主控器的时间,以便我可以重新订阅所需的频道?

发生这种情况时,无需手动检测故障转移并重新订阅频道,因为 Lettuce 会自行完成(请参阅 StatefulRedisPubSubConnectionImpl#activated())。