java zookeeper读取节点

时间:2025-04-12 07:09:24
import ; import ; import ; import ; import ; import ; public class ZKTest { public static void main(String[] args) { String connectString = "127.0.0.1:2181"; int sessionTimeout = 4000; Watcher watcher = new Watcher() { public void process(WatchedEvent event) { //(()); } }; try { ZooKeeper zooKeeper = new ZooKeeper(connectString, sessionTimeout, watcher); List<String> list = ("/dubbo", false); for (String path : list) { (path); } } catch (IOException e) { (); } catch (KeeperException e) { (); } catch (InterruptedException e) { (); } } }