Skip to content

Instantly share code, notes, and snippets.

@diegovar
Created October 4, 2013 14:04
Show Gist options
  • Save diegovar/6826414 to your computer and use it in GitHub Desktop.
Save diegovar/6826414 to your computer and use it in GitHub Desktop.
testing akka poisonpill
#!/bin/sh
exec scala "$0" "$@"
!#
import akka.actor._
object Venom
class Child extends Actor {
override def postStop {
println("child dying")
}
def receive = {
case Venom => context.stop(self)
}
}
class Parent extends Actor {
val child = context.actorOf(Props(new Child))
override def postStop {
println("parent dying")
}
def receive = {
case Venom =>
println("Kill all my children mwahahaha")
context.children.foreach( _ ! Venom)
context.stop(self)
}
}
object Main {
def main(args: Array[String]) {
val system = ActorSystem("LALA")
val parent = system.actorOf(Props(new Parent))
parent ! Venom
}
}
Main.main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment