说我有以下代码:
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")
并说如果actor是actor1Dispatcher,我只想在ConnectionException上重启一个actor,否则,我只想默认运行。这可能吗?我还没有发现任何东西可以只对一种类型的儿童演员进行调度。
答案 0 :(得分:0)
也许是这样的?
case ce: ConnectException if sender.path.name=="actor1Dispatcher" => Restart