ActorRef and ServiceKey references

How to get ActorSystem reference from non actor classes. In addition, how to get ActorRef or ServiceKey reference from non actor class.

Somewhere you start the ActorSystem. Reference to that instance must be passed in to where you need it.

There is no global reference to started ActorSystem in Akka, because it’s allowed to start and stop many systems in the same JVM. That is useful for testing.

Thanks Patrick. So I did register the worker router and service router to receptionist.

ActorRef<ClusterTaskService.Command> service = context.spawn(ClusterTaskService.create(workerRouter), "TaskService");
   context.getSystem().receptionist().tell(Receptionist.register(TASK_SERVICE_KEY, service.narrow()));

 boolean preferLocalRoutees=true;
   ActorRef<EngineComputeWorker.RunRequestCommand> workerRouter = context.spawn(Routers.group(TASK_WORKER_KEY).withRoundRobinRouting(preferLocalRoutees), "WorkerRouter");   

I registered the Service to receptionist so how can I get reference when I need to use it from receptionist, I couldn’t find API to get ActorRef Service from Receptionist

With Receptionist.Find message as described in https://doc.akka.io/docs/akka/current/typed/actor-discovery.html

However, if you are using a group router you can send messages directly to the ActorRef of the router, the ActorRef<ClusterTaskService.Command> service in your example.