1

Akka シングルトン クラスターのインスタンス メンバーとして、Akka クラスター シングルトン パターンで LEADER になるイベントをサブスクライブする方法。

application.conf は次のとおりです。

akka {
actor {
  provider = "akka.cluster.ClusterActorRefProvider"
  deployment {
    /singleton/registerService/workerRouter {
      router = consistent-hashing-pool
      nr-of-instances = 100
      cluster {
        enabled = on
        max-nr-of-instances-per-node = 3
        allow-local-routees = on
        use-role = registers
      }
    }
  }
}
remote {
  log-remote-lifecycle-events = off
  netty.tcp {
    hostname = "127.0.0.1"
    port = 0
  }
}

cluster {
  seed-nodes = [
    "akka.tcp://PashRegister@127.0.0.1:2051",
    "akka.tcp://PashRegister@127.0.0.1:2052"]

  auto-down-unreachable-after = 5s

  roles = ["registers"]
}
}
4

2 に答える 2

4

クラスター シングルトンの考え方は、ユーザーに代わって開始されるというものです。そのため、そのようなアクターが開始すると、それが「リーダー」になります (「シングルトンを実行する」など)。

于 2014-07-29T08:24:26.863 に答える