0

Say I have the following code:

  override val supervisorStrategy: SupervisorStrategy = {
    def defaultDecider: Decider = {
      case _: ActorInitializationException => Stop
      case _: ActorKilledException => Stop
      case ce: ConnectException => {
        log.info("ConnectException found. Restarting actor....")
        Restart 
      }
      case _: Exception  =>  Stop
    }

    OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = Duration.Inf)(defaultDecider)
  }
  val actor1Dispatcher = context.actorOf(Props[actor1Dispatcher], name = "actor1Dispatcher")
  val actor2Dispatcher = context.actorOf(Props[actor2Dispatcher], name = "actor2Dispatcher")
  val actor3Dispatcher = context.actorOf(Props[actor3Dispatcher], name = "actor3Dispatcher")

And say that I only want to restart an actor on a ConnectionException if the actor is a actor1Dispatcher, else, I just want to run as default. Is this possible? I haven't found anything to run the dispatch on only one type of child actor.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Soatl
  • 10,224
  • 28
  • 95
  • 153

1 Answers1

0

Maybe something like this?

case ce: ConnectException if sender.path.name=="actor1Dispatcher" => Restart