386장. 마스터 RoutePolicy
RoutePolicy 를 사용하여 마스터/슬레이브 모드에서 경로를 제어할 수도 있습니다.
이렇게 하는 경우 경로 정책을 구성해야 합니다.
- zookeeper의 URL
- 클러스터 그룹 이름
- 중요 한 후 경로를 자동 시작 하지 않도록 설정
작은 예
MasterRoutePolicy master = new MasterRoutePolicy();
master.setZooKeeperUrl("localhost:2181");
master.setGroupName("myGroup");
// its import to set the route to not auto startup
// as we let the route policy start/stop the routes when it becomes a master/slave etc
from("file:target/inbox?delete=true").noAutoStartup()
// use the zookeeper master route policy in the clustered group
// to run this route in master/slave mode
.routePolicy(master)
.log(name + " - Received file: ${file:name}")
.delay(delay)
.log(name + " - Done file: ${file:name}")
.to("file:target/outbox");
386.1. 예를 들면 다음과 같습니다. 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!