C# Class Akka.Persistence.PersistentView

A view replicates the persistent message stream of a PersistentActor. Implementation classes receive the message stream directly from the Journal. These messages can be processed to update internal state in order to maintain an (eventual consistent) view of the state of the corresponding persistent actor. A persistent view can also run on a different node, provided that a replicated journal is used. Implementation classes refer to a persistent actors' message stream by implementing `persistenceId` with the corresponding (shared) identifier value. Views can also store snapshots of internal state by calling [[autoUpdate]]. The snapshots of a view are independent of those of the referenced persistent actor. During recovery, a saved snapshot is offered to the view with a SnapshotOffer message, followed by replayed messages, if any, that are younger than the snapshot. Default is to offer the latest saved snapshot. By default, a view automatically updates itself with an interval returned by `autoUpdateInterval`. This method can be overridden by implementation classes to define a view instance-specific update interval. The default update interval for all views of an actor system can be configured with the `akka.persistence.view.auto-update-interval` configuration key. Applications may trigger additional view updates by sending the view Update requests. See also methods
Inheritance: Akka.Actor.ActorBase, ISnapshotter, IPersistentIdentity, IWithUnboundedStash, IPersistenceRecovery
ファイルを表示 Open project: rogeralsing/akka.net

Protected Properties

Property Type Description
Extension PersistenceExtension

Public Methods

Method Description
DeleteSnapshot ( long sequenceNr ) : void

Deletes the snapshot identified by sequenceNr. The PersistentActor will be notified about the status of the deletion via an DeleteSnapshotSuccess or DeleteSnapshotFailure message.

DeleteSnapshots ( SnapshotSelectionCriteria criteria ) : void

Deletes all snapshots matching criteria. The PersistentActor will be notified about the status of the deletion via an DeleteSnapshotsSuccess or DeleteSnapshotsFailure message.

LoadSnapshot ( string persistenceId, SnapshotSelectionCriteria criteria, long toSequenceNr ) : void

Instructs the snapshot store to load the specified snapshot and send it via an SnapshotOffer to the running PersistentActor.

SaveSnapshot ( object snapshot ) : void

Saves snapshot of current ISnapshotter state. The PersistentActor will be notified about the success or failure of this via an SaveSnapshotSuccess or SaveSnapshotFailure message.

Protected Methods

Method Description
OnReplayError ( Exception cause ) : void

Called whenever a message replay fails. By default it logs the error. Subclass may override to customize logging. The PersistentView will not stop or throw exception due to this. It will try again on next update.

PersistentView ( ) : System

Private Methods

Method Description
ChangeState ( ViewState state ) : void
ChangeStateToReplayStarted ( bool isAwait, long replayMax ) : void
CreateStash ( ) : IStash
Idle ( ) : ViewState

When receiving an Update event, switches to ReplayStarted state and triggers an incremental message replay. For any other message invokes actor default behavior.

IgnoreRemainingReplay ( Exception cause ) : ViewState

Consumes remaining replayed messages and then throws the exception.

OnReplayComplete ( ) : void

Switches to Idle.

OnReplayFailureCompleted ( Exception cause ) : void
RecoveryStarted ( long replayMax ) : ViewState

Processes a loaded snapshot, if any. A loaded snapshot is offered with a SnapshotOffer message to the actor's PersistentView.Receive method. Then initiates a message replay, either starting from the loaded snapshot or from scratch, and switches to ReplayStarted state. All incoming messages are stashed.

ReplayStarted ( bool shouldAwait ) : ViewState

Processes replayed message, if any. The actor's PersistentView.Receive is invoked with the replayed events. If replay succeeds it got highest stored sequence number response from the journal and then switche it switches to Idle state. If replay succeeds the OnReplaySuccess callback method is called, otherwise OnReplayError is called and remaining replay events are consumed (ignored). All incoming messages are stashed when shouldAwait is true.

UpdateLastSequenceNr ( IPersistentRepresentation persistent ) : void

Method Details

DeleteSnapshot() public method

Deletes the snapshot identified by sequenceNr. The PersistentActor will be notified about the status of the deletion via an DeleteSnapshotSuccess or DeleteSnapshotFailure message.
public DeleteSnapshot ( long sequenceNr ) : void
sequenceNr long
return void

DeleteSnapshots() public method

Deletes all snapshots matching criteria. The PersistentActor will be notified about the status of the deletion via an DeleteSnapshotsSuccess or DeleteSnapshotsFailure message.
public DeleteSnapshots ( SnapshotSelectionCriteria criteria ) : void
criteria SnapshotSelectionCriteria
return void

LoadSnapshot() public method

Instructs the snapshot store to load the specified snapshot and send it via an SnapshotOffer to the running PersistentActor.
public LoadSnapshot ( string persistenceId, SnapshotSelectionCriteria criteria, long toSequenceNr ) : void
persistenceId string
criteria SnapshotSelectionCriteria
toSequenceNr long
return void

OnReplayError() protected method

Called whenever a message replay fails. By default it logs the error. Subclass may override to customize logging. The PersistentView will not stop or throw exception due to this. It will try again on next update.
protected OnReplayError ( Exception cause ) : void
cause System.Exception
return void

PersistentView() protected method

protected PersistentView ( ) : System
return System

SaveSnapshot() public method

Saves snapshot of current ISnapshotter state. The PersistentActor will be notified about the success or failure of this via an SaveSnapshotSuccess or SaveSnapshotFailure message.
public SaveSnapshot ( object snapshot ) : void
snapshot object
return void

Property Details

Extension protected_oe property

protected PersistenceExtension Extension
return PersistenceExtension