我想测试一个使用ClusterSharing在某个时候询问EventSourcedBehaviorWithEnforcedReplies的函数
我像这样准备ClusterSharding:
ClusterSharding.get(testKit.system()).init(
Entity.of(
ENTITY_TYPE_KEY,
entityContext -> new Entity(entityContext.getEntityId())));
该函数发送命令:
CompletionStage<ActorAnswer> promisedAnswer = sharding
.entityRefFor(ENTITY_TYPE_KEY, identifier)
.ask(CommandToExecute::new, ASK_TIMEOUT)
CompletionStage永远不会执行...
我想念什么?
答案 0 :(得分:0)
经过相同的研究
1)检查您的application-test.conf
akka {
actor {
provider = cluster
}
}
2)需要创建集群并加入集群(自我加入),这是我发现的最简单的编程方式
Cluster cluster = Cluster.get(testKit.system());
cluster.manager().tell(Join.create(cluster.selfMember().address()));
3)然后我们可以讨论集群分片:)
ClusterSharding.get(testKit.system()).init(
clusterSharding.init(
Entity.of(ENTITY_TYPE_KEY, entityContext -> new Entity(entityContext.getEntityId())));