Akka Actor 监督 - 'resume' 是否保留当前消息?
Akka Actors Supervision - Does 'resume' keep current message?
在 Akka Actors(使用 Scala)中,可以使用监督策略来处理异常。该策略可以根据异常类型决定如何处理参与者。根据我的理解,有 4 种可能的结果:
- Resume- 让子actor保持当前状态,像什么都没发生一样继续处理新消息。
- 重新启动 - 重新启动子 actor,即杀死当前失败的子 actor 并在其位置创建一个新子 actor。
- 停止 - 永久关闭子actor。
- 上报 - 让主管的主管处理这个错误。
The documentation 明确指出,在重新启动 actor 时,当前消息将丢失,必须对此进行处理。但是,它没有明确提及是否同样适用于简历。它是继续处理该消息(假设某些外部因素导致了异常,但现在已不存在),还是继续处理邮箱中的下一条消息?
Does 'resume' keep current message?
没有
文档的 "what happens to the message" 部分描述了在参与者处理消息时抛出异常时的行为:
What happens to the message
If an exception is thrown while a message is being processed (i.e. taken out of its mailbox and handed over to the current behavior), then this message will be lost. It is important to understand that it is not put back on the mailbox. So if you want to retry processing of a message, you need to deal with it yourself by catching the exception and retry your flow. Make sure that you put a bound on the number of retries since you don’t want a system to livelock (so consuming a lot of cpu cycles without making progress).
以上行为适用于任何监督策略:恢复、重新启动或停止。 (“升级”是经典 Akka 中的第四种策略,但 is not explicitly supported in Akka Typed. However, escalation can be emulated in Akka Typed。)
在 Akka Actors(使用 Scala)中,可以使用监督策略来处理异常。该策略可以根据异常类型决定如何处理参与者。根据我的理解,有 4 种可能的结果:
- Resume- 让子actor保持当前状态,像什么都没发生一样继续处理新消息。
- 重新启动 - 重新启动子 actor,即杀死当前失败的子 actor 并在其位置创建一个新子 actor。
- 停止 - 永久关闭子actor。
- 上报 - 让主管的主管处理这个错误。
The documentation 明确指出,在重新启动 actor 时,当前消息将丢失,必须对此进行处理。但是,它没有明确提及是否同样适用于简历。它是继续处理该消息(假设某些外部因素导致了异常,但现在已不存在),还是继续处理邮箱中的下一条消息?
Does 'resume' keep current message?
没有
文档的 "what happens to the message" 部分描述了在参与者处理消息时抛出异常时的行为:
What happens to the message
If an exception is thrown while a message is being processed (i.e. taken out of its mailbox and handed over to the current behavior), then this message will be lost. It is important to understand that it is not put back on the mailbox. So if you want to retry processing of a message, you need to deal with it yourself by catching the exception and retry your flow. Make sure that you put a bound on the number of retries since you don’t want a system to livelock (so consuming a lot of cpu cycles without making progress).
以上行为适用于任何监督策略:恢复、重新启动或停止。 (“升级”是经典 Akka 中的第四种策略,但 is not explicitly supported in Akka Typed. However, escalation can be emulated in Akka Typed。)