在我的一个 Actor 中,我正在创建一个像这样的路由器 Actor child :
this.actorRouter = getContext().actorOf(Props.empty().withRouter(new BroadcastGroup(neighbours)), "router");
其中neighbours
是字符串列表(地址)。现在我希望能够更改该列表。例如,当来自未知参与者的新消息到达时,我想将他的地址添加到我的路由器中。我尝试使用新列表执行上面的行,但是,这会导致错误:
Actor name is already taken
广播组创建后是否可以对其进行操作?
最佳答案
来自the doc
管理消息
- 将 akka.routing.GetRoutees 发送到路由器 Actor 将使其发送 在 akka.routing.Routees 消息中返回当前使用的路由。
- 发送 akka.routing.AddRoutee 到路由器 Actor 会将该路由添加到其路由集合中。
- 发送 akka.routing.RemoveRoutee 到路由器 Actor 会将该路由移除到其路由集合中。
- 将 akka.routing.AdjustPoolSize 发送到池路由器 Actor 会在其路由集合中添加或删除该数量的路由。
关于java - 在 Akka 中向 BroadcastGroup 添加新地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43893409/