今後の呼び出しで何かを実行しています。私は成功した完了時に結果を送付者に返すか、または将来の呼びかけが失敗した場合に俳優を失敗させます。スーパバイザ戦略を適用したRoundRobinPoolが実装されている親によって処理されます。未来の呼び出しが失敗した場合にアクターに失敗する
ここにコードスニペットがあります。
private def getData(sender: ActorRef): Unit = {
dao.getData().mapTo[List[Data]].map(result => sender ! result)
.onFailure {
case e: NullPointerExcetpion => {
println("+++++++ Throwing exception")
// throwning the exception from here doesn't cause the supervisor to restart this actor
throw t
}
}
// throwing the exception from here makes the supervisor strategy to take action
throw new NullPointerExcetpion
}
未来が例外を返す場合、俳優を失敗させるにはどうすればいいですか?
乾杯、
UTSAV
あなたは「俳優の失敗」とはどういう意味ですか? –
それをユーザーに伝播させて、俳優を殺します。スーパーバイザーがアクターを再起動させるような動作。ヌルポインタ例外の場合、SupervisorStrategy.Restartがスーパーバイザで使用されるため。 – Utsav
もっと重要なのは、Future関数の外部から明示的にエラーを投げているときに、なぜそれが機能しているのですか? – Utsav