在AKKA中,在主管上调用关闭会阻止它监督的所有演员吗?

编程入门 行业动态 更新时间:2024-10-23 13:36:37
本文介绍了在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中,在主管上调用关闭会阻止它监督的所有演员吗?

本文发布于:2023-11-25 13:54:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:演员   AKKA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!