Created
October 4, 2013 14:04
-
-
Save diegovar/6826414 to your computer and use it in GitHub Desktop.
testing akka poisonpill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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