2 ノードの akka クラスターを構築しようとしましたが、両方のノードがシード ノードとして構成されています。各ノードでアクターを作成し、以下の方法で配置します。
akka {
//loglevel = "DEBUG"
log-config-on-start = on
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
remote {
log-remote-lifecycle-events = off
netty.tcp {
hostname = "127.0.0.1"
port = 0
}
}
cluster {
seed-nodes = [
"akka.tcp://ClusterSystem@127.0.0.1:2551",
"akka.tcp://ClusterSystem@127.0.0.1:2552"
]
roles = [
"transport"
]
auto-down = on
}
}
final String SINGLETON_GROUP = "client";
getContext().system().actorOf(
ClusterSingletonManager.defaultProps(
Props.create(ClientActor.class, channelActive.getCtx()),
loginMessage.getId(),
PoisonPill.getInstance(),
"transport"
), SINGLETON_GROUP
);
private ActorRef getActor(String id) {
ActorRef remoteActor = getContext().system().actorOf(
ClusterSingletonProxy.defaultProps("user/" + SINGLETON_GROUP + "/" + id,
"transport"));
return remoteActor;
}
私が期待していたのは、任意のノードでアクターを作成し、singletonPath を取得している限り、どこにでも配置できることです。ただし、結果は次のとおりです。getActor() は「リーダー」ノードでのみ機能し、他のノードでは識別できません。clusterSingleton について間違った理解をした場合は?