1

/user/master/"+startID和 和有什么不一样 /user/master/*?我假设 * 意味着StartRouteProcess消息将发送给所有参与者。这个对吗?然而, /user/master/"+startIDTask消息发送给给定的actorstartID

      case JoinNode =>
        val startID = Nodelist(Random.nextInt(numJoined))
        context.system.actorSelection("/user/master/" + startID) ! Task("Join", startID, Nodelist(numJoined), -1)

      case BeginRouting =>
        println("Node Join Finished.\n")
        println("Routing started.")
        context.system.actorSelection("/user/master/*") ! StartRouteProcess
4

1 回答 1

0

根据 akka 文档https://doc.akka.io/docs/akka/2.5/general/addressing.html#querying-the-logical-actor-hierarchy

可以使用 ActorSystem.actorSelection 和 ActorContext.actorSelection 方法来制定选择,并且支持发送消息:

context.actorSelection("../*") ! msg

会将 msg 发送给包括当前演员在内的所有兄弟姐妹。

所以你是对的。

于 2020-10-26T18:12:41.270 回答