AKKA:无痛演员错误通知 [英] AKKA: Painless Actor Error Notifications

查看:74
本文介绍了AKKA:无痛演员错误通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 一个组件美丽正在使用她内部 akka.actor.Actor 来执行某些操作。(例如执行)

  • A component BEAUTIFUL is using her internal akka.actor.Actor to do certain things.. ( such as "acting up" for example )

还有其他 MAN 组件确实希望与 BEAUTIFUL

There are other MAN components that would really like to "interact" with the BEAUTIFUL

美丽发现值得的 MAN 时,在进行交互之前和他一起,她同意输入他的电话号码(我们称它为 ErrorHandler ),如果他早上离开而忘记了,他会给他打电话他在床头柜上的劳力士

When the BEAUTIFUL finds a MAN worthy, before "interacting" with him, she agrees to take in his phone number ( let's call it an ErrorHandler ), you know just to give him a call in case he left in the morning and forgot his Rolex on her bed side table

美丽虽然是高维护成本(他们都..),并且每次 BEAUTIFUL 的内部Actor内部发生不良情况(例如, OmgBrokenNailException UglyPurseThrowable 等),她疯了,需要完全停下来并呼叫 MAN 使用该电话号码(例如 errorHandler.getOnItNowHoney(message,throwable)

The BEAUTIFUL though is "high maintenance" ( aren't they all.. ), and every time something bad happens inside the BEAUTIFUL's internal Actor ( e.g. an OmgBrokenNailException, UglyPurseThrowable, etc.. ), she goes nuts, needs to stop completely and to call a MAN using that phone number ( e.g. errorHandler.getOnItNowHoney( message, throwable ) )

AKKA主管允许注册两种类型的FaultHandlers => OneForOneStrategy AllForOneStrategy ,如果基础Actor覆盖preRestart / postRestart,则它可以访问实际的可抛出,例如:

AKKA supervisors allow to register two types of FaultHandlers => OneForOneStrategy and AllForOneStrategy, where if the underlying Actor overrides preRestart/postRestart, it gets access to an actual "throwable" e.g.:

override def preRestart( reason: Throwable ) { // do with throwable... }

问题是这两种策略都将尝试重新启动Actor,这不是我想要的。我正在寻找Actor用 throwable调用外部 ErrorHandler 并停止。

The problem is both of these strategies will try to restart the Actor(s), which is not something that I am looking for. I am looking for the Actor to call an external ErrorHandler with the "throwable" and stop.

如果我不这样做不要使用这些策略,当从A​​ctor中引发异常时,在Actor上调用 postStop ,这很酷,但它不会包含可抛出 :

If I don't use these strategies, when exception is thrown from within the Actor, a postStop is called on the Actor, which is cool, but it does not take in a "throwable":

override def postStop() { // no access to "throwable"... }

帮助 MAN 来获得 throwable

推荐答案

在Akka 2中,您应该使用死亡监视

In Akka 2 you should use DeathWatch

这篇关于AKKA:无痛演员错误通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆