How do I create an actor with a different path?

If you create an actor (no name), it will live on the way akka.tcp://system@$a#-576914160

. myGpurp

Is it possible to create an actor directly in a subdirectory ? For example. result: the path to the object will be akka.tcp://system@$a#-576914160



source to share

2 answers

You need to create an actor with a name myGpurp

and then ask the actor to create a child. This is the only way to get the path you want.



First you need to create named actor myGpurp:

val myGpurp: ActorRef = context.actorOf(Props(classOf[myGpurp]),"myGpurp")


In MyGpurp, you can create an anonymous or named actor:

import{Actor, ActorRef, Props}

class MyGpurp extends Actor {
  override def receive: Receive = {
    case m: Any =>
      val child: ActorRef = context.actorOf(Props(classOf[SomeActor]))
      child ! "Message"


The path to your SomeActor will be like akka.tcp: // system@ : 2552 / user / myGpurp / $ a # -576914160



All Articles