Class EnforceOutboxFenceRequest
Atomic leadership-fence compare-and-advance against the durable OutboxFence control table.
[NoTenantTerm(TenantConfinement.EstateWide, "the fence is keyed on the outbox table, not on a tenant: a fencing token orders competing processors of one table and has no tenant dimension to scope to")]
public sealed class EnforceOutboxFenceRequest : DataRequestBase<IDbConnection, long>, IDataRequest<IDbConnection, long>, IDataRequest
- Inheritance
-
EnforceOutboxFenceRequest
- Implements
- Inherited Members
Remarks
A single serializable MERGE both reads the recorded high-water and advances it monotonically to
the presented token — never lowering it. Because the whole compare-and-advance is one statement under
UPDLOCK, HOLDLOCK, two concurrent leaders cannot both advance the high-water: the second observes the
first's write and is ordered after it. The statement always emits exactly one row carrying the
resulting high-water:
- presented token >= recorded high-water → the high-water advances to (or stays at) the token, and the result equals the token (accepted);
- presented token < recorded high-water → the high-water is left unchanged, and the result is the recorded (higher) high-water (rejected — the caller was superseded).
The caller therefore decides staleness by comparing the returned high-water to the presented token: a returned value strictly greater than the token means the token was rejected, and that returned value is the recorded high-water to report on the fencing diagnostic. The high-water lives in a table cleanup never touches, so it survives the deletion of the token-bearing message rows.
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
EnforceOutboxFenceRequest(string, string, long, int, IDbTransaction?, CancellationToken)
Initializes a new instance of the EnforceOutboxFenceRequest class.
public EnforceOutboxFenceRequest(string fenceTableName, string scope, long fencingToken, int commandTimeout, IDbTransaction? transaction, CancellationToken cancellationToken)
Parameters
fenceTableNamestringThe qualified fence control table name.
scopestringThe fence scope key — the qualified outbox table name this fence guards.
fencingTokenlongThe leadership fencing token presented by the caller.
commandTimeoutintCommand timeout in seconds.
transactionIDbTransactionOptional transaction to participate in.
cancellationTokenCancellationTokenThe cancellation token.