When we create an Actor, what we get in response is an ActorRef
. This is a reference to our created Actor. Why we might need an ActorRef
is to pass throughout the system to other actors as a reference. These references are used for message passing. Every actor that we create has a reference to itself through self.
From within an actor, it's possible to obtain an actor reference of the calling Actor via a method named sender()
.
We can also give names to actor references. In our case, we named our SimpleActor
reference simple-actor:
val simpleActor: ActorRef = system.actorOf(props, "simple-actor")
We also know that these Actors are created in a hierarchical fashion and we can give unique names to actor instances. Hence, these names together make a path for each Actor. The path is unique for each Actor. Our SimpleActor
path might look like this:
We can see that due to the hierarchy, we have paths for different actors, because actors must have unique names. We can also...