akka 持久性,失败时恢复,至少一次语义

akka persistence, resume on failure, at least once semantics

我脑子里有点乱 避免邮箱中毒 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.

我的情况:演员收到 "command" 到 运行 smth。 Actor 尝试访问远程服务。服务不可用。抛出异常。我希望演员继续联系远程服务器。我不希望演员跳过导致异常的输入命令。 Resume 会帮助我强迫演员继续前进吗?

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

通过 Resume,我的意思是重试导致抛出异常的调用。我怀疑 akka Resume 意味着保留 actor 实例,但不会重试失败的调用

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

扩展第一个案例。 Actor 尝试访问远程服务。现在演员很执着。 SupervisorStrategy 强制 Actor 继续联系远程服务。整个 JVM 关闭。 Akka 应用程序重新启动。 Actor Resume 会从疲惫不堪的地方拼命到达远程服务吗?

akka持久化是指至少一次语义吗?

Actor 收到消息。然后 JVM 崩溃。 parent re-receive 它在 crush 期间处理的消息吗?

扩展我的评论:

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 指令将使 actor 在消息处理失败后继续运行。不过,重试消息的一种方法是实际上只使用 Restart 并利用 ActorpreRestart 挂钩:

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

当 actor 崩溃时,它会 运行 这个钩子并为您提供一个机会来处理导致它失败的消息。

Does akka persistence means durable mailboxes?

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

Does akka persistence means At least once semantics?

同样不一定,但该工具包确实有一个名为 AtleastOnceDelivery 的特性,可以让您实现这一点(和持久的邮箱)!

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