gpt4 book ai didi

akka.net - Akka.Persistence回收的顺序是什么?

转载 作者:行者123 更新时间:2023-12-02 01:22:56 25 4
gpt4 key购买 nike

我读过 Akka.Persistence intro在 Petabridge 博客上,我发现这部分代码有点困惑:

    Recover<string>(str => _msgs.Add(str)); // from the journal
Recover<SnapshotOffer>(offer => {
var messages = offer.Snapshot as List<string>;
if(messages != null) // null check
_msgs = _msgs.Concat(messages);
});

您可能想要在恢复时做的是......首先拍摄最后的快照,然后重播日志中的消息。

但是这里我们有两个 Recover() 声明,第一个是日志。当 Akka .NET 执行恢复时,这些 Recover() 方法的顺序实际上如何发挥作用?

最佳答案

Recover 仅用于在已声明的 actor 中注册消息处理程序,与 ReceiveActor 中的 Receive 的工作方式相同。因此声明恢复处理程序的顺序无关紧要。

来自下面的评论:

During recovery persistent actor first asks if there are any snapshots, it can use to recover from - therefore SnapshotOffer will always be triggered before rest of events. Then it asks for events that occurred after snapshot, it received. They will be processed in order, they come from event journal and processed by the first matching Recover handler.

关于akka.net - Akka.Persistence回收的顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38860291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com