akka - 有什么理由不建议使用关机方法?

标签 akka

关闭ActorSystem时,我发现不建议使用ActorSystem::shutdown。建议使用"Use the terminate() method instead"

但是这些方法的简化几乎是相同的:

  /**
   * Terminates this actor system. This will stop the guardian actor, which in turn
   * will recursively stop all its child actors, then the system guardian
   * (below which the logging actors reside) and the execute all registered
   * termination handlers (see [[ActorSystem#registerOnTermination]]).
   * Be careful to not schedule any operations on completion of the returned future
   * using the `dispatcher` of this actor system as it will have been shut down before the
   * future completes.
   */
  def terminate(): Future[Terminated]


  /**
   * Stop this actor system. This will stop the guardian actor, which in turn
   * will recursively stop all its child actors, then the system guardian
   * (below which the logging actors reside) and the execute all registered
   * termination handlers (see [[ActorSystem#registerOnTermination]]).
   */
  @deprecated("Use the terminate() method instead", "2.4")
  def shutdown(): Unit

一个异常(exception)是返回类型已更改。否决shutdown的原因是什么?它不安全吗?

最佳答案

似乎不赞成使用该项目的其他领域中使用的“终止”约定,并公开终止事件。

重要的是终止事件:

The termination hooks allow system actors to perform final cleanup before the system shuts down or restarts - in this particular case it's to let remote systems know that any remote-deployed actors on the shutting down system are dead, but there are other cases where this gets used inside Akka core



有关更多信息,请参见以下内容:
  • The related Akka issue
  • The related Akka.NET issue
  • The Actor system shutdown section of their 2.3 to 2.4 migration guide
  • 关于akka - 有什么理由不建议使用关机方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38292093/

    相关文章:

    scala - Akka Actor - 创建 Actor 池

    scala - 如何更改组合 future 的超时时间?

    Scala future 应用程序在完成之前终止

    playframework - 集群中 Akka Actor 的发现

    scala - akka 流 toMat

    postgresql - 使用 Slick 执行并发查询时出现 NullPointerException

    java - 知道 akka actors 何时完成

    scala - Akka Stream 中 map 和 mapAsync(1) 的结果

    docker - docker容器内的akka​​应用程序问题

    server - 什么网络服务器使用 akka akka-http 以及如何获取它的版本?