开发者

ZooKeeper: how to correctly reconnect when session expired?

开发者 https://www.devze.com 2023-03-06 12:15 出处:网络
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 z

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

精彩评论

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