Skip to content

Instantly share code, notes, and snippets.

@homerquan
Created November 15, 2017 19:34
Show Gist options
  • Save homerquan/12fe757980f73ce361b7a2efbfaf8952 to your computer and use it in GitHub Desktop.
Save homerquan/12fe757980f73ce361b7a2efbfaf8952 to your computer and use it in GitHub Desktop.
# Stop an actor
## PoisonPill Messages
A PoisonPill message has special handling for all actors, including for routers. When any actor receives a PoisonPill message, that actor will be stopped. See the PoisonPill documentation for details.
```scala
import akka.actor.PoisonPill
router ! PoisonPill
```
## Stop context
https://doc.akka.io/docs/akka/2.5/scala/actors.html#stopping-actors
```scala
class MyActor extends Actor {
val child: ActorRef = ???
def receive = {
case "interrupt-child" =>
context stop child
case "done" =>
context stop self
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment