Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

akka actors Toolkit - context.actorOf vs system.actorOf

Tags:

java

akka

actor

Could you please explain to me what is the difference between

context.actorOf

and

system.actorOf

?

like image 823
Vitali Melamud Avatar asked Dec 21 '16 13:12

Vitali Melamud


1 Answers

Answer to this can be easily found in the Akka documentation:

An actor system is typically started by creating actors beneath the guardian actor using the ActorSystem.actorOf method and then using ActorContext.actorOf from within the created actors to spawn the actor tree.

  • Actors spawned with System.actorOf will be children of the guardian actor.
  • Actors spawned with context.actorOf will be children of the context itself - i.e. the actor which invokes the method.

As a more general suggestion, make sure you thoroughly explore Akka docs when in search of similar answers.

like image 92
Stefano Bonetti Avatar answered Oct 01 '22 20:10

Stefano Bonetti