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 actors

Next we will go ahead and try creating the TypedActor objects within the ActorSystem context.

An actor with a default constructor

When the typed actor implementation has a default constructor, it is constructed using the following syntax.

Java:

ActorSystem _system = ActorSytem.create("TypedActorsExample");
CalculatorInt calculator = TypedActor.get(_system)
  .typedActorOf(new TypedProps<Calculator>(
  CalculatorInt.class,	Calculator.class));

Scala:

    val _system = ActorSystem("TypedActorsExample")
    val calculator1: CalculatorInt =
    TypedActor(_system).typedActorOf(TypedProps[Calculator]())

The typed actor has been implemented as an Akka extension. So to get hold of the extension, the following call gets the extension object—TypedActor.get(_system) ...

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