13.6. Stopping Actors
You want to stop one or more running Akka actors.
There are several ways to stop Akka actors. The most common ways
are to call
ActorSystem level or
context.stop(actorRef) from inside an
There are other ways to stop an actor:
Send the actor a
To demonstrate these alternatives, at the
ActorSystem level you can stop an actor by
Within an actor, you can stop a child actor by using the
An actor can also stop itself:
You can stop an actor by sending it a
gracefulStop is a little
more complicated and involves the use of a future. See the Discussion
for a complete example.
Table 13-2 provides a summary of the methods that you can use to stop an actor.
Table 13-2. Ways to stop actors
The actor will continue to process its current message (if any), but no additional messages will be processed. See additional notes in the paragraphs that follow.
Lets you attempt to terminate actors gracefully, waiting for them to timeout. The documentation states that this ...