有没有办法在演员主管的SupervisorStrategy中获得消息?我的意思是导致演员失败的人。我想从中获取一些数据。
可能的方法:
例如:
// The new exception type
case class MessageException(
akkaMessage: Any,
originalException: Throwable
) extends RuntimeException("Exception due to message")
// In the supervised actor
def receive = {
case msg => try{ process(msg) } catch {
case t => throw MessageException(msg,t)
}
}
// In the supervisor
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
case MessageException(msg,t) => //decide what to do
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句