Doubt on Lightbend akka cluster tutorial example

Am referring Lightbend tutorial for akka cluster.

What is the meaning of the below line ?

getContext().actorOf(
FromConfig.getInstance().props(Props.create(StatsWorker.class)),
“workerRouter”)

Is it creating new actor in type of StatsWorker or it is referring the actor which already created

What page are you looking at? Classic Cluster Aware Routers • Akka Documentation?

actorOf (javadoc) always creates a new actor.

Thanks raboof !!

https://doc.akka.io/docs/akka/current/cluster-routing.html#router-example-with-group-of-routees… from this link I have downloaded the Akka Cluster Sample with Java. In which StatsService.class contains the statement that I mentioned above.

As you mentioned above actorOf creates new actor that is okay
what is the use of this line FromConfig.getInstance().props
What it does ??
ActorRef workerRouter = getContext().actorOf(
FromConfig.getInstance().props(Props.create(StatsWorker.class)),
“workerRouter”);

Also one more question,
In the same example StatsSampleClient.java we are storing the address of each member into Set through which we are sending msg to an Actor for every 2 second.

My use case
Instead of sending msg to an actor I want to send a msg to cluster from which It should automatically redirect to any one of the Actor which is currently available.
Hope you understand my question…

Is it possible to achieve my use case

akka.router.FromConfig.getInstance() gets an object that can be used to create routers based on the configuration. The scaladoc is here, unfortunately it doesn’t seem to appear correctly in the javadoc, I filed this ticket for that.

Then .props(Props.create(StatsWorker.class)) creates the Props to create a router that routes to a pool of actors that are created with Props.create(StatsWorker.class).

Thanks raboof :grinning:

@raboof Could you please help me in this