我想测试一个函数,该函数在某些时候使用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从未被执行......
我缺少什么?
经过同样的研究
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())));