Table of Contents

Class OutboxMessage

Namespace
Excalibur.Outbox
Assembly
Excalibur.Outbox.dll

Represents a message stored in the outbox pattern for reliable message delivery.

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.PublicProperties)]
public record OutboxMessage : IOutboxMessage, IEquatable<OutboxMessage>
Inheritance
OutboxMessage
Implements
Inherited Members

Constructors

OutboxMessage()

Initializes a new instance of the OutboxMessage class.

public OutboxMessage()

Properties

Attempts

Gets or sets the number of dispatch attempts made for this message.

public int Attempts { get; set; }

Property Value

int

The current Attempts value.

CausationId

Gets the causation identifier of the message that caused this one, carried on the persisted row so it round-trips through the stage-then-reload path.

public string? CausationId { get; init; }

Property Value

string

The causation identifier, or null when none was carried.

CorrelationId

Gets the correlation identifier grouping this message with the wider business operation, carried on the persisted row so it round-trips through the stage-then-reload path.

public string? CorrelationId { get; init; }

Property Value

string

The correlation identifier, or null when none was carried.

CreatedAt

Gets the timestamp when the message was created.

public required DateTimeOffset CreatedAt { get; init; }

Property Value

DateTimeOffset

The current CreatedAt value.

Destination

Gets the delivery destination this message is routed to, carried on the persisted outbox row so it round-trips through the stage-then-reload path rather than being silently dropped.

public string? Destination { get; init; }

Property Value

string

The delivery destination, or null when none was carried.

DispatcherId

Gets or sets the optional identifier of the dispatcher handling this message.

public string? DispatcherId { get; set; }

Property Value

string

The current DispatcherId value.

DispatcherTimeout

Gets or sets the optional timeout for the dispatcher.

public DateTimeOffset? DispatcherTimeout { get; set; }

Property Value

DateTimeOffset?

The current DispatcherTimeout value.

ExpiresAt

Gets or sets the optional expiration timestamp for the message.

public DateTimeOffset? ExpiresAt { get; set; }

Property Value

DateTimeOffset?

The current ExpiresAt value.

GroupKey

Gets the group key used for logical message grouping, carried on the persisted row so it round-trips through the stage-then-reload path.

public string? GroupKey { get; init; }

Property Value

string

The group key, or null when none was carried.

IsMultiTransport

Gets a value indicating whether this message is delivered to multiple transports, carried on the persisted row so it round-trips through the stage-then-reload path.

public bool IsMultiTransport { get; init; }

Property Value

bool

true when the message targets multiple transports; otherwise false.

LastError

Gets the persisted failure information used to resume a pending recovery disposition.

public string? LastError { get; init; }

Property Value

string

The last recorded failure, or null before a failure is recorded.

MessageBody

Gets the serialized message body as raw bytes.

public required byte[] MessageBody { get; init; }

Property Value

byte[]

The current MessageBody value.

Remarks

Stored as byte[] so binary, compressed, or encrypted payloads round-trip losslessly — a string body would corrupt any non-UTF8 content.

MessageId

Gets the unique identifier for the message.

public required string MessageId { get; init; }

Property Value

string

The current MessageId value.

MessageMetadata

Gets the serialized message metadata.

public required string MessageMetadata { get; init; }

Property Value

string

The current MessageMetadata value.

MessageType

Gets the type of the message.

public required string MessageType { get; init; }

Property Value

string

The current MessageType value.

PartitionKey

Gets the partition key used to preserve ordered delivery within a partition, carried on the persisted row so it round-trips through the stage-then-reload path.

public string? PartitionKey { get; init; }

Property Value

string

The partition key, or null when none was carried.

Priority

Gets the delivery priority (higher values indicate higher priority), carried on the persisted row so it round-trips through the stage-then-reload path.

public int Priority { get; init; }

Property Value

int

The priority level; 0 when none was specified.

ScheduledAt

Gets the time before which the message must not be delivered, carried on the persisted row so a future-scheduled message is not treated as immediately deliverable after a stage-then-reload.

public DateTimeOffset? ScheduledAt { get; init; }

Property Value

DateTimeOffset?

The scheduled delivery time, or null when the message is deliverable immediately.

SequenceNumber

Gets the sequence number enforcing ascending in-partition delivery order, carried on the persisted row so it round-trips through the stage-then-reload path.

public long SequenceNumber { get; init; }

Property Value

long

The sequence number, or 0 when none was carried.

TargetTransports

Gets the comma-separated set of target transports this message is routed to, carried on the persisted row so it round-trips through the stage-then-reload path.

public string? TargetTransports { get; init; }

Property Value

string

The target transports, or null when none was carried.

TenantId

Gets the tenant identifier this message was produced under (overrides the TenantId default so the Postgres outbox store's persisted tenant_id column round-trips).

public string? TenantId { get; init; }

Property Value

string

The tenant identifier, or null when no tenant scope was carried.

Methods

Equals(OutboxMessage?)

Determines whether the specified OutboxMessage is equal to the current instance, comparing MessageBody by content rather than by reference.

public virtual bool Equals(OutboxMessage? other)

Parameters

other OutboxMessage

The other message to compare against.

Returns

bool

true if the messages are equal; otherwise false.

Remarks

The compiler-synthesized record equality compares the MessageBody byte array by reference, which would make two records carrying identical payloads unequal. This override restores value semantics by comparing the payload bytes structurally, keeping the record's value-equality contract intact for a binary body.

FromOutboundMessage(OutboundMessage)

Creates an OutboxMessage from an OutboundMessage, carrying the common fields — including TenantId — in one place so no provider stage path silently drops tenant scope during the OutboundMessage → OutboxMessage conversion.

public static OutboxMessage FromOutboundMessage(OutboundMessage message)

Parameters

message OutboundMessage

The outbound message to convert.

Returns

OutboxMessage

An outbox message carrying the outbound message's id, type, headers, payload, and tenant.

Remarks

This is the canonical conversion: provider outbox stores route their stage paths through it rather than re-inlining the bare constructor (which omits TenantId). It owns the common-field mapping (id, type, headers, payload, created-at, tenant).

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.