本文介绍了在AKKA中,在主管上调用关闭会阻止它监督的所有演员吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一位主管已经联系了两位演员。当我的应用程序关闭时,我想优雅地关闭这些演员。调用supervisor.shutdown()会停止所有演员还是我还需要手动停止我的演员?

Let's say I have a supervisor that has linked 2 actors. When my app shutsdown I want to shutdown those actors gracefully. Does calling supervisor.shutdown() stop all the actors or do I still need to stop my actors manually?

gracias

推荐答案

(调用 Supervisor.stop())停止所有链接(受监督)演员:

Stopping a supervisor (calling Supervisor.stop()) stops all linked (supervised) actors:

final class SupervisorActor{
...
   override def postStop(): Unit = shutdownLinkedActors

但是,如果要优雅地关闭系统中的所有actor,还有另一个,使用Actor Registry(包含系统范围内所有演员的信息):

However, when you want to shutdown all actors in the system gracefully, there's another proper way to do that, using Actor Registry (that holds information about all the actors systemwide):

Actor.registry.shutdownAll

这篇关于在AKKA中,在主管上调用关闭会阻止它监督的所有演员吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 18:21