This repository has been archived by the owner on Mar 16, 2022. It is now read-only.
Add restart on failure option for event sourced entities #439
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For #375. This adds support for restarting entities on user failures, for the case of emitted events before fail is called, while allowing events to be applied immediately to have updated state.
Use actor restart to retain the mailbox. The stream relay functionality is moved to a separate actor, so that it can be a stable relay actor ref for the entity when reconnecting the stream. The entity actor still has its own custom command stash. We could use standard actor stash (and persistent actors use a separate stash internally) but because there are only
stash
andunstashAll
public methods, with several commands queued it would mean un-stashing all of them and then re-stashing messages again, for each command processed. We would also lose the instrumentation for the command stash that we have now. So instead use the (akka private) prepending to the mailbox that actor stash uses, but only unstash back to the mailbox on restarts. Prepending means that we always retain command order, even if there are recently arrived messages in the mailbox.Update java-support to apply emitted events immediately, reverting back to the earlier behaviour, and use the entity restart option on failures if events have been emitted. Update the TCK model test for event sourced, now that state is updated in responses again. For the emit-then-fail test in the TCK, it currently always expects the restart option to be used. If language supports optimise this by keeping local snapshots, or have a different approach to atomicity, then this test will need to be updated to test either approach. We can wait until we get to that point though.