Aaronontheweb on dev
Provide static GetRoutees.Insta… (compare)
I had a code:
var events = CurrentState.Change(); PersistAll(events, e => Publisher.Publish(e)); SaveSnapshot(CurrentState);
And it produce invalid snapshots sometimes - it cannot be restored from persisted events. I assume some of events can be lost.
So I'm looking for a way to save snapshot after all events will be persisted, not just one.
Now switched to
var events = CurrentState.Change(); PersistAll(events, e => Publisher.Publish(e)); var state = CurrentState; Defer(state, s => SaveSnapshot(s));
and for me it makes sequence of:
start execute command (Receive)
mutate state (var events = Aggregate.ExecuteCommand(e))
save events (PersistAll)
atomic - while we are in Receive block, no other command can be processed, when we are saving via PersistAll, no other command can be processed
OnPersistRejectedmethod, but this won't cause actor to stop