Skip to content

Instantly share code, notes, and snippets.

@samueltardieu
Created January 28, 2012 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueltardieu/1696035 to your computer and use it in GitHub Desktop.
Save samueltardieu/1696035 to your computer and use it in GitHub Desktop.
import akka.actor._
import akka.event.Logging
object Bug extends App {
ActorSystem("Bug").actorOf(Props[Bug])
}
class Bug extends Actor with FSM[Int, (Int, Int)] {
import FSM._
override val log = Logging(context.system, this)
self ! new Exception("foo")
startWith(0, (0, 1))
when(0) {
case Event('ack, _) =>
log.info("Received ack")
stay
case Event(t: Throwable, _) =>
log.info("Received throwable " + t)
self ! new Exception("bar")
goto(1)
}
when(1) {
case Event('ack, _) =>
log.info("Received ack")
stay
case Ev(t: Throwable) =>
log.info("Received throwable " + t)
stop(Normal)
}
initialize
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment