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@192.168.1.2:2552/user/$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@192.168.1.2:2552/user/myGpurp/$a#-576914160
.
+3
source to share
2 answers
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 akka.actor.{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@192.168.1.2 : 2552 / user / myGpurp / $ a # -576914160
+4
source to share