February 2018
Intermediate to advanced
552 pages
13h 46m
English
To create an Actor in Akka, we should first create its runtime environment, that is, the ActorSystem. We use this ActorSystem to create top-level Actors using the actorOf() function, as shown:
val actorSystem = ActorSystem("SimpleActorSystem")
val actorRef = actorSystem.actorOf(Props[SimpleActor]) // or use the following overloaded actorOf() function
val actorRef = actorSystem.actorOf(Props[SimpleActor], "Simple")
Here, ActorSystem.actorOf() takes Props, and we should provide the Actor name as the type annotation.
Like ActorSystem.actorOf() is useful to create top-level Actors; we can also use ActorContext.actorOf() with the same parameters to create subordinate or child Actors. However, we should use this function with ...
Read now
Unlock full access