In my use case, I have a variable number of independent ActorSystems. As a new system starts up, it initiates a simple Syn/Ack procedure with the command and control system, allowing the C&C to deploy remote actors. Just for fun, here is some example code.
Lets start with our remote system:
objectRemoteextendsApp{valsystem=ActorSystem("RemoteSystem",ConfigFactory.defaultReference(getClass.getClassLoader))valconnStr="akka://CommandSystem@<ip>:2555/user/CommandActor"valcnc=system.actorFor(connStr)valsynActor=system.actorOf(Props[SynActor])}classSynActorextendsActor{overridedefpreStart={//Send the syn
Remote.cnc!newSyn}defreceive={casea:Ack=>//
}}
Some shared classes:
caseclassSyn()caseclassAck()
Now the Command and Control system and the actual code you want run remotely:
objectCommandextendsApp{valsystem=ActorSystem("CommandSystem",ConfigFactory.defaultReference(getClass.getClassLoader))valcncActor=system.actorOf(Props[CommandActor])}classCommandActorextendsActor{defreceive={cases:Syn=>//Respond for politeness
sender!newAck//Get the remote actorsystem path
valaddr=AddressFromURIString(sender.path.root.toString)//Push the actor to the remote system
valremoteActor=context.actorOf((Props[RemoteActor]).withDeploy(Deploy(scope=RemoteScope(addr))))}}classRemoteActorextendsActor{//Where you put your remote code implementation
}
From here, you can handle management of remote actors in whichever way you want. Fun stuff!