I created a simple scenario. The following actor systems:
akka.tcp://[email protected]:2560
akka.tcp://[email protected]:2570
akka.tcp://[email protected]:2580
The idea is to create an "SampleActor" from 127.0.0.1:2570 but deploy the actor creation to 127.0.0.1:2560 using the configuration stated on the documentation: Creating Actors Remotely
akka {
actor {
deployment {
/sampleActor {
remote = "akka.tcp://[email protected]:2560"
}
}
}
}
And then on 127.0.0.1:2570:
system.actorOf(Props.create(SampleActor.class), "sampleActor");
Now from 127.0.0.1:2580 I wan to find the remote deployed actor and send a message. According to the docs: Looking up Remote Actors
ActorSelection selection =
system.actorSelection("akka.tcp://[email protected]:2560/user/sampleActor");
selection.tell("Pretty slick", ActorRef.noSender());
However this does not work. It cannot find the actor on 127.0.0.1:2560. But it works if I change to:
ActorSelection selection =
system.actorSelection("akka.tcp://[email protected]:2570/user/sampleActor");
selection.tell("Pretty slick", ActorRef.noSender());
The difference is that on the first one I am looking for the actor where it is deployed, in this case in 127.0.0.1:2560, as the docs say, and on the second case I am looking for the actor where the actor creation was defined, in this case is 127.0.0.1:2570. Why is this happening?, it doesn't make sense, if I am looking for a remote actor then I should look at the place where it was deployed right? Also when printing the parent at the deployed actor I get:
akka://TestSystem/remote/akka.tcp/[email protected]:2570/user
This makes it more confusing as it is not the same as described on the docs: The Interplay with Remote Deployment All of this makes it really confusing, the docs are really long and don't explain properly how to do some basic things properly. Can someone please help me understand this issue?