Table of Contents

Interface IEventNotificationBroker

Namespace
Excalibur.EventSourcing
Assembly
Excalibur.EventSourcing.Abstractions.dll

Orchestrates in-process event notification after events have been committed to the event store.

public interface IEventNotificationBroker

Remarks

The broker is invoked by EventSourcedRepository.SaveAsync immediately after IEventStore.AppendAsync succeeds. It invokes the registered IEventNotificationHandler<TEvent> instances sequentially, one event at a time in commit order. Inline completion then drives the ordered projection processor, which applies committed events in global-stream order.

This interface is resolved from DI as a nullable service. When no broker is registered, SaveAsync skips broker notification; this does not guarantee zero execution overhead.

Important: Because events are already committed when the broker runs, callers must NOT retry SaveAsync if notification fails. The save succeeded; only a handler did not.

Methods

NotifyAsync(IReadOnlyList<IDomainEvent>, EventNotificationContext)

Notifies the registered event notification handlers about committed events.

Task<ProjectionCompletion> NotifyAsync(IReadOnlyList<IDomainEvent> events, EventNotificationContext context)

Parameters

events IReadOnlyList<IDomainEvent>

The domain events that were committed, in order.

context EventNotificationContext

Context about the aggregate that produced the events.

Returns

Task<ProjectionCompletion>

Whether this save's Inline projections reached the context's global position: NotRequested when no projection is registered Inline, Attested when they were observed to have folded the prefix through it against the roster as it then stood, and BoundExpired when the bounded wait ended first. The value is RETURNED rather than thrown because the events are already committed: an exception here reports a failed save that did not fail, and every retry policy in the ecosystem would repeat the command.

Remarks

This method takes no cancellation token, and the omission is the contract. It runs after the events are durable, so a caller that gives up cannot un-commit them -- the only thing its cancellation could still achieve is leaving the read model unapplied while the caller is told a durable save failed. Accepting a token would make that outcome expressible at every call site; not accepting one makes it expressible at none.

Notification delivery and Inline completion each use PostCommitTimeout, on their own clock, so an unresponsive store still cannot hold a save open forever.

Exceptions

Exception

A failing handler's own exception is rethrown with its stack trace preserved, when FailurePolicy is Propagate.