Reputation: 333
I am trying to conditionally change an actor's Recovery object. When an actor spins up and there are no snapshots or events that have been persisted, I restart the actor. Upon restarting I want to change the Recovery
object. This is how I currently have my actor set up:
protected Recovery _recovery = Recovery.Default;
public override Recovery Recovery => _recovery;
And in the PostRestart()
method, I have:
protected override void PostRestart(Exception reason)
{
// EmptyJournalException is a custom exception
if (reason is EmptyJournalException)
{
// Other code here...
_recovery = new Recovery(SnapshotSelectionCriteria.None);
}
}
However, when going through the recovery process again, it is still applying snapshots. If I change the value of _recovery
to ignore snapshots in the constructor, it works as expected. However, when setting it in PostRestart()
, it gets ignored.
What is the best way to conditionally set the Recovery
property? I am wanting to only set it when restarting the actor because of an EmptyJournalException
.
Upvotes: 0
Views: 89