在AKKA中,在主管上调用关闭会阻止它监督的所有演员吗?
假设我有一个链接了两个演员的主管。 当我的应用程序关闭时,我想优雅地关闭这些演员。 调用supervisor.shutdown()会停止所有演员还是我还需要手动停止我的演员?
格拉西亚斯
停止主管 (调用Supervisor.stop()
)会停止所有链接(受监督)的actor:
final class SupervisorActor{ ... override def postStop(): Unit = shutdownLinkedActors
但是,当你想要优雅地关闭系统中的所有actor时,还有另一种正确的方法 ,使用Actor Registry(它保存有关系统范围内所有actor的信息):
Actor.registry.shutdownAll