Skip to content

Instantly share code, notes, and snippets.

@jamie-allen
Created November 4, 2011 18:48
Show Gist options
  • Save jamie-allen/1340137 to your computer and use it in GitHub Desktop.
Save jamie-allen/1340137 to your computer and use it in GitHub Desktop.
/**
* I'm trying to create a basic supervisor hierarchy with four actors. If any fail for
* any reason, tear them all down and restart them to re-process any unhandled
* data. When I run, I see the "Blowing up!" log output. I expect the ensuing throw
* to blow up my actors, and then I should see all of my actors restarted per my
* supervision strategy, but I just get a message timeout (None response to the
* producer).
*
* The online Akka docs say this about sending a message with a ?: "The receiving
* actor should reply to this message, which will complete the future with the
* reply message as value; if the actor throws an exception while processing the
* invocation, this exception will also complete the future." If the exception is
* "completing" the future, is that why my actor ? message is timing out instead
* of failing?
*
* Supervisor is constructed in an error kernel actor like so:
*/
supervisor = Some(Supervisor(
SupervisorConfig(
AllForOneStrategy(List(classOf[Throwable]), 10, 5000),
Supervise(dao, Permanent) ::
Supervise(queue, Permanent) ::
Supervise(producer, Permanent) ::
Supervise(consumer, Permanent) ::
Nil)))
/**
* producer, after startup, fires a message to dao and awaits reply via future
*/
(dao ? GetUpdates).as[DaoResponse] match {
case Some(_) => println("Got response")
case None => println("Response timed out")
}
/**
* dao handle the GetUpdates message, but throws an exception
*/
def receive = {
case (GetEntitlementUpdates) =>
logger.debug("BLOWING UP!")
throw new RuntimeException("Blowd up!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment