Click or drag to resize
Akka.NETEventsourcedPersistAsyncTEvent Method
Asynchronously persists an event. On successful persistence, the handler is called with the persisted event. Unlike PersistTEvent(TEvent, ActionTEvent) method, this one will continue to receive incoming commands between calls and executing it's event handler. This version should be used in favor of PersistTEvent(TEvent, ActionTEvent) method when throughput is more important that commands execution precedence. 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: (
public void PersistAsync<TEvent>(
	TEvent event,
	Action<TEvent> handler


Type: TEvent
Type: SystemActionTEvent

Type Parameters

See Also