How to stop an Akka actor (and shutdown the Akka system)

Akka actor FAQ: How do you stop an Akka actor?

I don't have time this morning to write my usual tutorial, so in short, if you want to stop an Akka actor, use code like this from inside your actor's receive method:

context.stop(self)

Or, if you want to shut down the Akka system, use the following code, again from inside the receive method of one of your actors:

context.system.shutdown()

I'll write more about this in the future, but in the meantime you can see examples of this in the Typesafe/Akka "Pi" calculating example.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.