What is the method for an actor to send a message to its parent?
I'm using Akka 2.2
In Akka, you can stop Actors by invoking the stop() method of either ActorContext or ActorSystem class. ActorContext is used to stop child actor and ActorSystem is used to stop top level Actor.
Companion object ActorSystem An actor system is a hierarchical group of actors which share common configuration, e.g. dispatchers, deployments, remote capabilities and addresses. It is also the entry point for creating or looking up actors. There are several possibilities for creating actors (see akka.
You are looking for
getContext().parent()
which gives you the ActorRef of the parent, so you can do
getContext().parent().tell(...)
With Akka 2.4, you have to do context.parent
inside an actor to have its parent actor reference. After that, you can send it a message as before (context.parent ! "hello"
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With