Skip to content

Instantly share code, notes, and snippets.

@stefanobaghino
Created June 1, 2015 08:21
Show Gist options
  • Save stefanobaghino/63d5460215a6257a82db to your computer and use it in GitHub Desktop.
Save stefanobaghino/63d5460215a6257a82db to your computer and use it in GitHub Desktop.
package warboys
import akka.actor._
object WarBoyActor {
def props: Props = Props(new WarBoyActor)
case object WitnessMe
}
class WarBoyActor extends Actor with ActorLogging {
import WarBoyActor._
@throws[Exception](classOf[Exception])
override def preStart(): Unit = {
super.preStart()
log.info("I LIVE! I DIE! I LIVE AGAIN!")
}
@throws[Exception](classOf[Exception])
override def postStop(): Unit = {
super.postStop()
log.info("WITNESS ME!")
}
def receive: Receive = {
case WitnessMe =>
context.watch(sender)
log.info("MEDIOCRE!")
case Terminated(_) =>
log.info("I WITNESS YOU!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment