I have a setup in which an actor(A) creates an actor(B) which it supervises and restarts when it crashes. From outside the actor system I want to get some value from the ‘nested’ actor B.
I can directly ask the actorSystem for the nested actor using:
val nestedActorB = myActorSystem.actorFor("/user/A/B")
Can I keep a reference to this actor or should I ask the actorSystem for the ref each time I want to ask the nested actor something. (Or should I ask the parent actor for the ref)?
What would be a best practice in this scenario?
(scala 2.9.1 and akka 2.0.4)
Thanks,
Albert
Yes you can keep a reference to the actor and not ask the system every time with
actorFor.There is a difference between local and remote actors and the documentation passage you are referring to is ambiguous and I’ve opened a ticket.
A local actor is only looked up once during the
actorForcall so it needs to exist before you look it up, while sends to a remote actor are always by path and the remote actor is looked up on the remote node every time.