关闭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
有关更多信息,请参见以下内容:
关于akka - 有什么理由不建议使用关机方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38292093/