Class GetUnsentMessagesRequest
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
tableNamestringThe qualified outbox table name.
batchSizeintMaximum number of messages to retrieve.
commandTimeoutintCommand timeout in seconds.
leaseTimeoutSecondsintLease timeout in seconds for stale lease reclamation.
processorIdstringIdentifier of the claiming processor.
fencingTokenlong?The fencing token for the caller's current leadership tenure, or null when no fencing applies. When non-null, rows are claimed only if
fencingTokenis greater than or equal to the recorded fencing high-water mark; claimed rows have theirFencingTokencolumn 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
OutboxFencecontrol table (keyed byfenceScope), not fromMAX(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.fenceTableNamestringThe qualified durable fence control table name.
fenceScopestringThe fence scope key — the qualified outbox table name this fence guards.
cancellationTokenCancellationTokenThe cancellation token.