4
votes

According to the Akka docs on the System Guardian, if a top-level actor throws an Exception, it will be restarted indefinitely (with 2 exceptions - no pun intended).

My actor system has 1 and only 1 top-level actor: Initializer. If Initializer throws an exception, I would like a different SuervisorStrategy applied to it, if at all possible:

  • Restart Initializer up to 3 times
  • If that doesn't work, then stop/terminate it

How could I implement this custom strategy for the System Guardian?

1

1 Answers

4
votes

You can set the guardian supervision strategy with the configuration key akka.guardian-supervisor-strategy in your application.conf, which has the default "akka.actor.DefaultSupervisorStrategy".

See this section of the docs for more info: http://doc.akka.io/docs/akka/current/general/configuration.html#akka-actor