您如何订阅哨兵并从他们那里接收出版物?
How do you subscribe to sentinel and receive publication from them?
我正在尝试使用 pub/sub impl。在 Jedis 上获取有关 master 倒下的信息,但我不确定如何订阅 Sentinel 频道。
我的发布者class:
public Publisher(Jedis publisherJedis, String channels, String clusterName) {
this.publisherJedis = publisherJedis;
this.channels = channels;
this.clusterName = clusterName;
}
public void start() {
log.info("publishing on channel +odown");
try {
while(true) {
if(JedisPoolFactory.getMasterDown(clusterName)) {
publisherJedis.publish("+odown", "master down, master down");
}
}
} catch(Exception ex) {
log.error("failure with end of stream catching.", ex);
}
}
我必须将我的哨兵注册为发布者,我需要做的就是在每次发生主故障转移时解码消息。我该如何订阅 sentinel 频道?
正如antirez所说,您可以使用普通的Jedis实例连接到sentinel,并订阅频道。和Redis完全一样 pub/sub.
我正在尝试使用 pub/sub impl。在 Jedis 上获取有关 master 倒下的信息,但我不确定如何订阅 Sentinel 频道。
我的发布者class:
public Publisher(Jedis publisherJedis, String channels, String clusterName) {
this.publisherJedis = publisherJedis;
this.channels = channels;
this.clusterName = clusterName;
}
public void start() {
log.info("publishing on channel +odown");
try {
while(true) {
if(JedisPoolFactory.getMasterDown(clusterName)) {
publisherJedis.publish("+odown", "master down, master down");
}
}
} catch(Exception ex) {
log.error("failure with end of stream catching.", ex);
}
}
我必须将我的哨兵注册为发布者,我需要做的就是在每次发生主故障转移时解码消息。我该如何订阅 sentinel 频道?
正如antirez所说,您可以使用普通的Jedis实例连接到sentinel,并订阅频道。和Redis完全一样 pub/sub.