When we make a call to method actorOf, what we get in return is an ActorRef that in turn also possesses a particular path where we've created the Actor. With this call, we know exactly there's an Actor instance created, been assigned a unique ID, and hook methods are called. There's this method named preStart() that gets called as the very first action, after a new Actor is created.
A few points to note when a new Actor is created:
- A new Actor path is reserved for the Actor
- A unique ID is assigned to the Actor
- After the instance is created, the preStart() method is called:
When an Actor is restarted:
- The preRestart() is called on the instance.
- New instance is created, replaces the old instance.
- The postRestart() method is called.
When an Actor is stopped:
- The postStop()Â method is called on the instance.
- Terminated...