1
votes

I'm reading the Akka docs on Actor Selection and trying to understand how it works. Specifically, I'm trying to understand the naming convention Akka uses for setting the paths to specific actors based on their location in the actor "tree" and their name.

My understanding is

  • All actors are available under the "root" path called /user/
  • On creation (via actorSystem.actorOf(Props[ActorClassImpl], name = "SomeName")) all Actors are given a name
  • The "path" to an Actor is the /user/ prefix plus a hierarchy path (see below) plus their name
  • The "hierarchy path" is just a slash-delimited concatentation of all the parents between /user/ and the actor

Hence if an actor with a name of fizz is a root-level actor, and it has a child named buzz, and that child itself has a child named foo, then the path to foo is /user/fizz/buzz/foo, yes?

So to begin with, if my understanding of how this basic path construction works is incorrect, please begin by correcting me! Assuming I'm more or less correct, are there any "invalid" names for actors, such as actors with whitespaces or punctuation in their names?

1

1 Answers

2
votes
  • All actors are available under the "root" path called /user/

All user-created actors are found below the "/user/" guardian actor. The actor at "/" is the root guardian. There are other actors that are found below the root guardian as described here.

  • On creation (via actorSystem.actorOf(Props[ActorClassImpl], name = "SomeName")) all Actors are given a name

In this example, a top-level ActorClassImpl actor is created with the name "SomeName".

  • The "path" to an Actor is the /user/ prefix plus a hierarchy path (see below) plus their name
  • The "hierarchy path" is just a slash-delimited concatentation of all the parents between /user/ and the actor

Hence if an actor with a name of fizz is a root-level actor, and it has a child named buzz, and that child itself has a child named foo, then the path to foo is /user/fizz/buzz/foo, yes?

For user-created actors, that's partially correct. The actor path also includes an anchor. For example:

"akka://MyActorSystem/user/fizz/buzz/foo"                      // local
"akka.tcp://[email protected]:1234/user/fizz/buzz/foo // remote

...are there any "invalid" names for actors, such as actors with whitespaces or punctuation in their names?

From the documentation:

The name parameter is optional, but you should preferably name your actors, since that is used in log messages and for identifying actors. The name must not be empty or start with $, but it may contain URL encoded characters (eg. %20 for a blank space). If the given name is already in use by another child to the same parent an InvalidActorNameException is thrown.