Table of Contents

Class GetUnsentMessagesRequest

Namespace
Excalibur.Outbox.SqlServer.Requests
Assembly
Excalibur.Outbox.SqlServer.dll

Data request to get unsent messages from the outbox.

[NoTenantTerm(TenantConfinement.EstateWide, "the outbox drain is cross-tenant by design: one dispatcher serves every tenant, and the row carries TenantId so the handler can re-establish the owning tenant per message. Scoping this read to the ambient tenant would stall delivery for every other tenant")]
public sealed class GetUnsentMessagesRequest : DataRequestBase<IDbConnection, IEnumerable<OutboxMessageRow>>, IDataRequest<IDbConnection, IEnumerable<OutboxMessageRow>>, IDataRequest
Inheritance
GetUnsentMessagesRequest
Implements
Inherited Members

Remarks

This framework-owned request uses its fixed constructor-defined primitive input schema. Replacing a known parameter value through Parameters is observed at execution; parameter DbType, direction, size, templates and output callbacks are not an extensibility contract of this request. Custom IDataRequest implementations retain their own execution behavior.

Constructors

GetUnsentMessagesRequest(string, int, int, int, string, long?, string, string, CancellationToken)

Initializes a new instance of the GetUnsentMessagesRequest class. Uses UPDATE...OUTPUT with lease columns to atomically claim and fetch messages, preventing double-processing by concurrent processors.

public GetUnsentMessagesRequest(string tableName, int batchSize, int commandTimeout, int leaseTimeoutSeconds, string processorId, long? fencingToken, string fenceTableName, string fenceScope, CancellationToken cancellationToken)

Parameters

tableName string

The qualified outbox table name.

batchSize int

Maximum number of messages to retrieve.

commandTimeout int

Command timeout in seconds.

leaseTimeoutSeconds int

Lease timeout in seconds for stale lease reclamation.

processorId string

Identifier of the claiming processor.

fencingToken long?

The fencing token for the caller's current leadership tenure, or null when no fencing applies. When non-null, rows are claimed only if fencingToken is greater than or equal to the recorded fencing high-water mark; claimed rows have their FencingToken column atomically advanced to this value as part of the same claim. A stale (superseded) token yields zero claimable rows rather than throwing.

The high-water mark is read from the durable OutboxFence control table (keyed by fenceScope), not from MAX(FencingToken) over the message rows. Because cleanup never deletes that control row, the high-water outlives the purge of sent, token-bearing rows, so a superseded leader's stale token stays rejected across a cleanup. This affects only the leadership high-water guard; the per-message lease still prevents two processors from claiming the same row.

fenceTableName string

The qualified durable fence control table name.

fenceScope string

The fence scope key — the qualified outbox table name this fence guards.

cancellationToken CancellationToken

The cancellation token.