Akka.Persistence恢复的顺序是什么?

What is the order of Akka.Persistence recovery?

我已经阅读了 Petabridge 博客上的 Akka.Persistence intro,我发现这部分代码有点混乱:

    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.