Reputation: 3232
In Akka when should I create an Actor using system.actorOf()
vs context.actorOf()
?
I know context.actorOf()
creates a child actor, but when should one actor be a child of another vs top level?
Upvotes: 1
Views: 1245
Reputation: 22126
you should avoid creating actors under the System actor. It's usually a good strategy to have new Actors as Children of your own (context) actor and group them accordingly and hierarchically.
That way you have better granularity to control the life cycle of your Actors, which implies you can control how many instances of each type of actor you need at any time (dynamically).
http://doc.akka.io/docs/akka/2.4/scala/actors.html
http://getakka.net/docs/Actor%20lifecycle
Upvotes: 1