If I create an actor using context().actorOf() in Akka, I get back a valid ActorRef. However, if I do the same but create an ActorRef using actorFor and the path I know that the actor will appear at, I do not reliably get a valid ActorRef back. How can I tell that an actor has been registered successfully?
In the description above, I could simply use the ActorRef returned from actorOf(). However, in my actual case I create an actor that itself registers a child actor and I need to resolve that, so the problem in general is "how can I wait / register to be informed of an actor having been registered at a known path?".
First of all, there's no guarantee that the ActorRef you get back from actorOf is still alive, since the constructor of it could have failed.
Secondly, actorFor might find the actor but it died just after being found and just before you started working with it.
Thirdly, it's normally good practice to structure your application so that dependencies are propagated in a logical fashion, so that there is a natural rendez-vous point between your actors.
Hope any of the above helps,
happy hAkking!
√