Create an Akka actor remotely without a new ActorSystem

浪尽此生 提交于 2019-12-06 14:12:37

I think what it sounds like you want to do is deploy a set of actors to a set of remote nodes and then sit them behind a local router and pass messages to the router and let it farm the work out to the remote nodes. To do that, you could try something like this:

val addresses = for(i <- 1 until 12) 
  yield AddressFromURIString(s"akka://RemoteSys@192.168.1.$i:2553")

val routerRemote = system.actorOf(Props[RemoteChild].withRouter(
  RemoteRouterConfig(RoundRobinRouter(12), addresses)))

This assumes that you have Akka running on those nodes with an ActorSystem called RemoteSys and it's using remoting configured for port 2553. When you send a message to that routerRemote ref, it will now round-robin route the messages across your 12 worker nodes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!