Click or drag to resize
Akka.NETEventsourcedPersistTEvent Method (TEvent, ActionTEvent)
Asynchronously persists an event. On successful persistence, the handler is called with the persisted event. This method guarantees that no new commands will be received by a persistent actor between a call to PersistTEvent(TEvent, ActionTEvent) and execution of it's handler. It also holds multiple persist calls per received command. Internally this is done by stashing. The stash used for that is an internal stash which doesn't interfere with the inherited user stash. An event handler may close over eventsourced actor state and modify it. Sender of the persistent event is considered a sender of the corresponding command. That means one can respond to sender from within an event handler. Within an event handler, applications usually update persistent actor state using persisted event data, notify listeners and reply to command senders. If persistence of an event fails, OnPersistFailure(Exception, Object, Int64) will be invoked and the actor will unconditionally be stopped. The reason that it cannot resume when persist fails is that it is unknown if the event was actually persisted or not, and therefore it is in an inconsistent state. Restarting on persistent failures will most likely fail anyway, since the journal is probably unavailable. It is better to stop the actor and after a back-off timeout start it again.

Namespace:  Akka.Persistence
Assembly:  Akka.Persistence (in Akka.Persistence.dll) Version: 1.1.3.30 (1.1.3.30)
Syntax
public void Persist<TEvent>(
	TEvent event,
	Action<TEvent> handler
)

Parameters

event
Type: TEvent
TBD
handler
Type: SystemActionTEvent
TBD

Type Parameters

TEvent
TBD
See Also