While overriding the default supervisorStrategy, all we do is define the value with arguments and provide a Decider; this decider contains the logic to be implemented in case of exceptions. It looks like this:
import akka.actor.SupervisorStrategy.{Resume, Restart} override val supervisorStrategy = OneForOneStrategy( maxNrOfRetries = 3, withinTimeRange = 1 minute ){ case _: ArithmeticException => { log.info("Supervisor handling ArithmeticException! n Resuming!") Resume } case _: Exception => { log.info("Supervisor handling Exception! n Restarting!") Restart } }
Here, we have defined a OneForOneStrategy, and on a case by case basis, the action to be performed in regards to the failing actor. A full example with this strategy in place can look like...