akka持久性,至少在语义上一次失败后恢复 [英] akka persistence, resume on failure, at least once semantics

查看:169
本文介绍了akka持久性,至少在语义上一次失败后恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我头上乱七八糟
避免邮箱中毒
http://doc.akka.io/docs/akka/2.4.2/general/supervision.html


然后,新角色恢复处理其邮箱,这意味着在角色本身之外看不到
重新启动,但值得注意的是
例外,即消息

The new actor then resumes processing its mailbox, meaning that the restart is not visible outside of the actor itself with the notable exception that the message during which the failure occurred is not re-processed.

我的情况:演员收到运行命令的命令 。 Actor尝试访问远程服务。服务不可用。引发异常。我希望演员继续与远程服务器联系。我不希望演员跳过导致异常的输入命令。 恢复会帮助我迫使演员继续前进吗?

My case: actor receives the "command" to run smth. Actor tries to reach remote service. Service is unavailable. Exception is thrown. I want actor to keep going contact remote server. I don't wan't actor to skip input command which caused exception. Will Resume help me to force actor to keep going?

override val supervisorStrategy: SupervisorStrategy =
    OneForOneStrategy(maxNrOfRetries = -1, withinTimeRange = 5.minutes) {
      case _: RemoteServiceIsDownException => Resume
      case _ => Stop
    }

通过恢复,我的意思是重试调用导致引发异常。我怀疑akka 恢复意味着保留角色实例,但不重试失败的调用

By Resume, I mean retry the invocation that caused the exception to be thrown. I suspect that akka Resume means keep actor instance, but not retry failed invocation

akka持久性是否意味着持久邮箱?

扩展第一种情况。 Actor尝试访问远程服务。现在演员是执着的。 SupervisorStrategy强制Actor继续联系远程服务。整个JVM关闭。 Akka应用程序已重新启动。演员会在疲惫不堪的情况下恢复到远程服务吗?

Extending first case. Actor tries to reach remote service. Now actor is persistent. SupervisorStrategy forces Actor to continue to contact remote service. The whole JVM shuts down. Akka app is restarted. Will Actor Resume from the point where it tired desperately reach remote service?

akka持久性是否至少意味着一次语义?

Does akka persistence means At least once semantics?

演员收到消息。然后,JVM崩溃。

Actor receives message. Then JVM crashes. Will parent re-receive message it was processing during crush?

推荐答案

扩大我的评论:


简历将帮助我迫使演员继续前进吗? ...通过Resume,我的意思是重试导致引发异常的调用。我怀疑akka Resume意味着保留actor实例,但不能重试失败的调用

Will Resume help me to force actor to keep going? ... By Resume, I mean retry the invocation that caused the exception to be thrown. I suspect that akka Resume means keep actor instance, but not retry failed invocation

不,我不相信。 Resume 指令将使参与者在您的消息处理失败后继续追赶。但是,重试消息的一种方法是实际上只使用 Restart 并利用 Actor preRestart 钩子:

No, I do not believe so. The Resume directive will keep the actor chugging along after your message processing failure. One way to retry the message though, is to actually just use Restart and to take advantage of an Actor's preRestart hook:

override def preRestart(t: Throwable, msgBeforeFailure: Option[Any]): Unit = {
  case t: RemoteServiceIsDownException if msgBeforeFailure.isDefined =>
     self ! msgBeforeFailure.get
  case _: =>
}

当演员崩溃时,它将运行此钩子并为您提供机会处理导致邮件失败的消息。

When the actor crashes, it will run this hook and offer you an opportunity to handle the message that caused it to fail.


akka持久性是否意味着持久邮箱?

Does akka persistence means durable mailboxes?

不一定,使用持久性actor只是意味着该actor的域事件以及随后的内部状态是持久的,而不是它用来处理消息的邮箱。话虽如此,可以很容易地实现持久邮箱,请参见下文。

Not necessarily, using a persistent actor just means that the actor's domain events, and subsequently, internal state is durable, not the mailbox it uses to process messages. That being said, it is possible to implement a durable mailbox pretty easily, see below.


akka持久性是否至少意味着一次语义? / p>

Does akka persistence means At least once semantics?

不一定,但该工具包确实具有一个称为 AtleastOnceDelivery 的特征您实现了这个(也是持久的邮箱)!

Again not necessarily, but the toolkit does have a trait called AtleastOnceDelivery to let you achieve this (and durable mailbox)!

请参见 http://doc.akka.io/docs/akka/current/scala/persistence.html#At-Least-Once_Delivery

这篇关于akka持久性,至少在语义上一次失败后恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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