Table of Contents

Class EventNotificationContext

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

Provides context about the aggregate whose events are being notified, passed to NotifyAsync(IReadOnlyList<IDomainEvent>, EventNotificationContext) and HandleAsync(TEvent, EventNotificationContext, CancellationToken).

public sealed record EventNotificationContext : IEquatable<EventNotificationContext>
Inheritance
EventNotificationContext
Implements
Inherited Members

Remarks

On IsReplay. Stated here rather than on the parameter because a member carries one remarks block: two of them meant the generator kept one and dropped the other, and the one it dropped was this correction.

CORRECTED. This parameter was previously documented as "a catch-up read of the global stream sets this … it must never be hard-coded", and both halves were wrong in ways that cost a consumer their side effects.
  • A catch-up read is NOT a replay. Events committed before a subscription started are ones it has never applied, so no effect has been performed for them; classifying them as re-deliveries told handlers to skip effects that never happened.
  • The live subscription DOES hard-code it, to false, and that is the only sound value: it reads strictly above its own checkpoint, so nothing it delivers can be something its own durable mark says it already applied. The re-fold paths hard-code true for the same reason — replay is a property of the operation, not a position to compare.
  • It is NOT a duplicate-suppression mechanism. It is false on a redelivery after a crash or a reader overlap, because such a delivery is not a re-fold of history. A handler with effects outside the projection state must be idempotent on the event identifier; no flag the framework computes can substitute for that.

On GlobalPosition.

Why the position is carried. A projection write that is conditional on which prefix of the stream is already folded into it needs that prefix as a number, and the apply path is the only place that knows which events it just folded. Without it the store can express the guarantee and no caller can supply the argument. It is null on the save path, where the events are being committed and no global position has been assigned yet.

Constructors

EventNotificationContext(string, string, long, DateTimeOffset, bool, long?)

Provides context about the aggregate whose events are being notified, passed to NotifyAsync(IReadOnlyList<IDomainEvent>, EventNotificationContext) and HandleAsync(TEvent, EventNotificationContext, CancellationToken).

public EventNotificationContext(string AggregateId, string AggregateType, long CommittedVersion, DateTimeOffset Timestamp, bool IsReplay = false, long? GlobalPosition = null)

Parameters

AggregateId string

The unique identifier of the aggregate that produced the events.

AggregateType string

The type name of the aggregate.

CommittedVersion long

The aggregate version after the events were committed.

Timestamp DateTimeOffset

The UTC timestamp when the notification was created.

IsReplay bool

true when the delivery is part of a DELIBERATE re-fold of stored history — a rebuild, a recovery, or an on-demand build. It is a property of the operation, set by whatever asked for the re-fold.

GlobalPosition long?

The global-stream position of the last event in this notification, or null when the events do not come from a global-stream read.

Remarks

On IsReplay. Stated here rather than on the parameter because a member carries one remarks block: two of them meant the generator kept one and dropped the other, and the one it dropped was this correction.

CORRECTED. This parameter was previously documented as "a catch-up read of the global stream sets this … it must never be hard-coded", and both halves were wrong in ways that cost a consumer their side effects.
  • A catch-up read is NOT a replay. Events committed before a subscription started are ones it has never applied, so no effect has been performed for them; classifying them as re-deliveries told handlers to skip effects that never happened.
  • The live subscription DOES hard-code it, to false, and that is the only sound value: it reads strictly above its own checkpoint, so nothing it delivers can be something its own durable mark says it already applied. The re-fold paths hard-code true for the same reason — replay is a property of the operation, not a position to compare.
  • It is NOT a duplicate-suppression mechanism. It is false on a redelivery after a crash or a reader overlap, because such a delivery is not a re-fold of history. A handler with effects outside the projection state must be idempotent on the event identifier; no flag the framework computes can substitute for that.

On GlobalPosition.

Why the position is carried. A projection write that is conditional on which prefix of the stream is already folded into it needs that prefix as a number, and the apply path is the only place that knows which events it just folded. Without it the store can express the guarantee and no caller can supply the argument. It is null on the save path, where the events are being committed and no global position has been assigned yet.

Properties

AggregateId

The unique identifier of the aggregate that produced the events.

public string AggregateId { get; init; }

Property Value

string

AggregateType

The type name of the aggregate.

public string AggregateType { get; init; }

Property Value

string

CommittedVersion

The aggregate version after the events were committed.

public long CommittedVersion { get; init; }

Property Value

long

GlobalPosition

The global-stream position of the last event in this notification, or null when the events do not come from a global-stream read.

public long? GlobalPosition { get; init; }

Property Value

long?

IsReplay

true when the delivery is part of a DELIBERATE re-fold of stored history — a rebuild, a recovery, or an on-demand build. It is a property of the operation, set by whatever asked for the re-fold.

public bool IsReplay { get; init; }

Property Value

bool

Timestamp

The UTC timestamp when the notification was created.

public DateTimeOffset Timestamp { get; init; }

Property Value

DateTimeOffset