Javatpoint Logo
Javatpoint Logo

Akka Props

Props is a configuration class which is used to specify options while creating an actor. It is immutable, so it is thread-safe and shareable.

You can implement Props by importing akka.actor.Props package.

You can create actor by passing a Props instance into the actorOf() factory method which is available in ActorSystem and ActorContext. The actorOf() method returns an instance of ActorRef. This instance is immutable and has one to one relationship with the actor it represents. ActorRef is also serializable so that you can serialize it.

In the following example, we are creating an Actor by using Props.

Akka Actor Example: by using Props

Output:

Hello from PropExample


There are various other ways to implement Props. Let's see an example.

Akka Actor Example2: by using Props

Where name is not given explicitly, it will be automatically generated.

Output:

Hello $a		// Reference of the name of actor	
Hello Actor2							
Hello Actor4							
Hello Actor3
Hello Actor5	
Next TopicAkka Child Actor





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA