-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Closed
Copy link
Labels
help wantedIssues that the core team will likely not have time to work onIssues that the core team will likely not have time to work ont:persistence
Milestone
Description
I have a PersistentActor
that wants to self-initialize like such:
@Override
public PartialFunction<Object, BoxedUnit> receiveRecover() {
return ReceiveBuilder
.match(RecoveryCompleted.class, msg -> {
if (lastSequenceNr() == 0) {
persist(createInitialEvent(), e -> {
updateSomeState();
});
}
})
.build()
.orElse(super.receiveRecover());
}
However, incoming commands aren't stashed between persisting the createInitialEvent()
and getting the callback to updateSomeState()
(which does happen eventually, I think as the next command is handled).
In EventSourcing.scala
, the reason is that the detecting of pendingStashingPersistInvocations
isn't performed until the state reaches processingCommands
. Perhaps a well-placed changeState(persistingEvents)
inside recoveryStarted(...)
or recovering(...)
could make it work.
Otherwise, blow up if persist()
is invoked during receiveRecover.
Metadata
Metadata
Assignees
Labels
help wantedIssues that the core team will likely not have time to work onIssues that the core team will likely not have time to work ont:persistence