174.7.3. 在集群内保留单例路由

以下代码片段演示了如何将单例使用者路由保留在 Camel 上下文的群集中。一旦 master 节点出现问题,其中一个从节点就被选为新的 master 并已启动。在这个特定示例中,我们希望使 singleton jetty 实例侦听地址的 http://localhost:8080/orders` 上的请求。

JGroupsLockClusterService service = new JGroupsLockClusterService();
service.setId("uniqueNodeId");
...
context.addService(service);

from("master:mycluster:jetty:http://localhost:8080/orders").to("jms:orders");