Akka 故障恢复:门控状态

Akka Failure Recovery: Gated State

akka documentation 表示如果 link 与远程系统处于封闭状态,则所有出站消息都将被丢弃。这是否意味着他们将立即投递到死信,或者只有在状态变为隔离时才会投递到死信?

日志明确说明了隔离状态,但不是封闭状态:

Association with remote system [...] has failed,
address is now gated for [5000] ms. Reason: [Disassociated]

Association to [...] having UID [...] is irrecoverably failed.
UID is now quarantined and all messages to this UID will be delivered to dead letters. 
Remote actorsystem must be restarted to recover from this situation.

虽然 gated 所有消息都进入死信状态,但它们不会以任何方式被缓冲和重新发送 - 换句话说,没有传递保证,如果你想要你需要在你的演员中为此添加额外的逻辑(文档的相关部分:http://doc.akka.io/docs/akka/2.4/general/message-delivery-reliability.html)

DeathWatch 可以避免向已死亡的 actor 发送消息,但是不能保证您不会在它死亡后但在您的 actor 收到终止消息之前向它发送消息, 因此这不足以建立交付保证。

根据您的需要,实施交付保证可以是 "light" 与远程参与者的简单确认协议,或 "heavy" AtLeastOnce(文档:http://doc.akka.io/docs/akka/2.4/scala/persistence.html#at-least-once-delivery-scala) 它将在不丢失消息的情况下处理节点崩溃。