开发者

ZooKeeper: how to correctly reconnect when session expired?

ZooKeeper FAQ tells that ZooKeeper object must be recreated when state becomes SESSION_EXPIRED.

Are there any examples of code that does such reconnection properly? Recipe开发者_开发技巧s folder in zookeeper distro contains two examples of code that both assume that session never expires. This is naïve, because after server gets diconnected from ZooKeeper cluster for 5 minutes, both queue and lock won't work again after connectivity reestablished.


ZkClient does that you can look at the code. It also has a listener implementation where you could register a listener implementation and get a persistent notification when the session expires

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜