第374章 Master 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");

374.1. 関連項目

  • Configuring Camel (Camel の設定)
  • コンポーネント
  • エンドポイント
  • スタートガイド