Pergunta

In Akka 2.0, is there a nice way to shut down all actors under the path /user? For example, let's say that I do the following:

val system = ActorSystem.create("mySystem")

system.actorOf(Props(new MyActor1), "actor1")
system.actorOf(Props(new MyActor2), "actor2")

Some time later, I decide I want to stop all of the actors in the system. If I understand things correctly, actor1 and actor2 will be children of the path /user, but I don't see a method that gives me an iterable of the children of an ActorRef. Is there another way?

Foi útil?

Solução

Use an actor selection to send a PoisonPill to all top-level actors:

system.actorSelection("/user/*") ! PoisonPill
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top