有没有理由弃用关机方法?

时间:2016-07-10 12:54:08

标签: 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

但有一个例外,即返回类型已更改。弃用shutdown的原因是什么?它不安全吗?

1 个答案:

答案 0 :(得分:7)

似乎弃用是遵循"终止"在项目的其他领域使用的惯例,以及揭露终止事件。

重要的部分是终止事件:

  

终止挂钩允许系统参与者在系统关闭或重新启动之前执行最终清理 - 在这种特殊情况下,它允许远程系统知道关闭系统上的任何远程部署的actor已经死亡,但是在其他情况下,这可以在Akka核心内部使用

有关详细信息,请参阅以下内容: