--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/6US5oDeGPugJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
(There's even a test which uses this technique, I just don't remember the name right now)
Regards,
Roland
have you've tried just having an actor statically consufigured, that receives messages containing Props, spawns the props and replies with the newly spawned actor?
Does that suffice?
I got it working - the trick was to specify the remote address both as a Config and as a RemoteScope instance:def registerRemoteDeployment(system: ActorSystem, path: ActorPath, remoteHost: String, remotePort: Int) {val deployer = system.asInstanceOf[ActorSystemImpl].provider.deployerval remoteUri = "akka://%s@%s:%s/".format(system.name, remoteHost, remotePort)val systemAddress = RemoteAddressExtractor.unapply(remoteUri).orElse(throw new Exception("Failed to parse URI"))val remoteCfg = ConfigFactory.parseString("remote: \"%s\"".format(remoteUri))val deployment = Deploy(path.elements.tail.mkString("/", "/", ""), remoteCfg, None, NoRouter, RemoteScope(systemAddress.get))deployer.deploy(deployment)}
This would then be used from an actor like:class SomeActor extends Actor {// ...def spawnChild(name: String) = {registerRemoteDeployment(context.system, self.path / name, 192.168.1.2, 2552)context.actorOf(Props[SomeChildActor], name)}}A bit clunky (and not very DRY) - but it works (for now). Any suggestions for improvements are welcome.Thanks for adding the issue Roland - It would be really great if there was a native API for specifying the deployment details on 'actorOf' on ActorContext/ActorSystem.
As a side-note: I tried creating a custom ActorRefProvider extending the default RemoteActorRefProvider to override the "actorOf" -- this would have made the custom deployment code a bit more clean. Unfortunately this was not possible since the InternalActorRef class is not accessible outside of its package. Is this by design?