386.5. Example
您可以保护集群的 Camel 应用程序,使其仅消耗来自一个活跃节点的文件。
// the file endpoint we want to consume from String url = "file:target/inbox?delete=true"; // use the zookeeper master component in the clustered group named myGroup // to run a master/slave mode in the following Camel url from("zookeeper-master:myGroup:" + url) .log(name + " - Received file: ${file:name}") .delay(delay) .log(name + " - Done file: ${file:name}") .to("file:target/outbox");
ZooKeeper 默认连接到 localhost:2181
,但您可以在组件级别上配置它。
MasterComponent master = new MasterComponent(); master.setZooKeeperUrl("myzookeeper:2181");
但是,您也可以使用环境变量配置 ZooKeeper ensemble 的 url。
export ZOOKEEPER_URL = "myzookeeper:2181"