문제

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?

도움이 되었습니까?

해결책

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

system.actorSelection("/user/*") ! PoisonPill
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top