기본적으로 Actor
은 다시 시작할 때 아이들을 처분합니다. 당신이 부모 중지하고 아이를 주시 해제됩니다 볼 수 있듯이
/**
* User overridable callback: '''By default it disposes of all children and then calls `postStop()`.'''
* @param reason the Throwable that caused the restart to happen
* @param message optionally the current message the actor processed when failing, if applicable
* <p/>
* Is called on a crashed Actor right BEFORE it is restarted to allow clean
* up of resources before Actor is terminated.
*/
@throws(classOf[Exception]) // when changing this you MUST also change UntypedActorDocTest
//#lifecycle-hooks
def preRestart(reason: Throwable, message: Option[Any]): Unit = {
context.children foreach { child ⇒
context.unwatch(child)
context.stop(child)
}
postStop()
}
다음은 Actor.preRestart
코드입니다.
override def preRestart(reason: Throwable, message: Option[Any]): Unit =()
그래서 당신의 목적을 위해 당신이
preRestart
를 오버라이드 (override) 할 필요가 없습니다 당신은 원하는 동작을 얻을 것이다 : 당신은 배우가 살아 아이들의 유지하기 위해 이런 식으로 재정의 할 수 있습니다. 시작시 자식 시작과 같은 사용자 정의 동작을 원하지만 재시작 이벤트에서는 그렇지 않은 경우 다른 콜백을 볼 수 있습니다.
자녀를 어떻게 만듭니 까? 부모 초기화 중 또는 수신 중 무조건적으로 어떻게해야합니까? –
@AlekseyIzmailov 수신시. – Lasf
부모 초기화 중이 아닌 수신시 작성된 자식은 중지되지만 다시 작성되지 않은 것처럼 보입니다. 그러나, 나는 이것을 확신하지 못했다. 누구나 이것이 실제 행동인지 확인할 수 있습니까? – Lasf