Document ActorSystem termination (#22863)

This commit is contained in:
Richard Imaoka 2017-05-09 21:40:46 +09:00 committed by Patrik Nordwall
parent 75de6119af
commit de668e89e6
2 changed files with 17 additions and 3 deletions

View file

@ -507,6 +507,7 @@ abstract class ActorSystem extends ActorRefFactory {
* Multiple code blocks may be registered by calling this method multiple times.
* The callbacks will be run sequentially in reverse order of registration, i.e.
* last registration is run first.
* Note that ActorSystem will not terminate until all the registered callbacks are finished.
*
* Throws a RejectedExecutionException if the System has already shut down or if shutdown has been initiated.
*
@ -520,6 +521,7 @@ abstract class ActorSystem extends ActorRefFactory {
* Multiple code blocks may be registered by calling this method multiple times.
* The callbacks will be run sequentially in reverse order of registration, i.e.
* last registration is run first.
* Note that ActorSystem will not terminate until all the registered callbacks are finished.
*
* Throws a RejectedExecutionException if the System has already shut down or if shutdown has been initiated.
*/
@ -527,8 +529,8 @@ abstract class ActorSystem extends ActorRefFactory {
/**
* 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
* will recursively stop all its child actors, the system guardian
* (below which the logging actors reside) and then 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
@ -538,7 +540,9 @@ abstract class ActorSystem extends ActorRefFactory {
/**
* Returns a Future which will be completed after the ActorSystem has been terminated
* and termination hooks have been executed. Be careful to not schedule any operations
* and termination hooks have been executed. If you registered any callback with
* [[ActorSystem#registerOnTermination]], the returned Future from this method will not complete
* until all the registered callbacks are finished. Be careful to not schedule any operations
* on the `dispatcher` of this actor system as it will have been shut down before this
* future completes.
*/

View file

@ -169,3 +169,13 @@ in which messages are processed in large systems is not controllable by the
application author, but this is also not intended. Take a step back and relax
while Akka does the heavy lifting under the hood.
Terminating ActorSystem
-----------------------
When you know everything is done for your application, you can call the
``terminate`` method of ``ActorSystem``. That will stop the guardian
actor, which in turn will recursively stop all its child actors, the system
guardian.
If you want to execute some operations while terminating ``ActorSystem``,
look at ``CoordinatedShutdown`` [:ref:`Java <coordinated-shutdown-java>`, :ref:`Scala <coordinated-shutdown-scala>`]