O'Reilly logo

Akka Essentials by Munish K. Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an actor hierarchy

To create child actors under a typed actor, we need to get the TypedActor context and then invoke the actorOf method.

Java:

//create a child actor under the Typed Actor context
ActorRef childActor = TypedActor.context().actorOf(
            new Props(ChildActor.class), "childActor");

Scala:

import TypedActor.context
//create a child actor under the Typed Actor context
val childActor:ActorRef = context.actorOf(Props[ChildActor],name="childActor")

Note

Remember, TypedActor.context() is only valid within methods of a TypedActor implementation.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required