Class MarkMessageFailedRequest
Data request to mark a message as failed in the outbox.
[NoTenantTerm(TenantConfinement.IdentityAddressed, "the outbox Id is the table's primary key, so this statement already addresses at most one row. The drain claims across tenants and hands back a row addressed by that globally-unique Id, so the mark must be able to address the row the claim returned; a tenant term could only subtract that row, never redirect the statement to a different one")]
public sealed class MarkMessageFailedRequest : DataRequestBase<IDbConnection, int>, IDataRequest<IDbConnection, int>, IDataRequest
- Inheritance
-
MarkMessageFailedRequest
- Implements
- Inherited Members
Constructors
MarkMessageFailedRequest(string, string, string, int, string, int, CancellationToken, DateTimeOffset?, int?)
Initializes a new instance of the MarkMessageFailedRequest class.
public MarkMessageFailedRequest(string tableName, string messageId, string errorMessage, int retryCount, string leasedBy, int commandTimeout, CancellationToken cancellationToken, DateTimeOffset? nextAttemptAt = null, int? floorSeconds = null)
Parameters
tableNamestringThe qualified outbox table name.
messageIdstringThe message ID to mark as failed.
errorMessagestringThe error message.
retryCountintThe current retry count.
leasedBystringBARE processor identity of the caller marking the message failed. This is deliberately NOT the value stored in
LeasedBy: the claim stamps a per-call{processorId}:{claimId}, so an equality test against a bare identity matches no claimed row at all. The guard matches it by PREFIX, and the update still only affects the row when it is unleased or leased by THIS processor, so a stale processor cannot overwrite a message a peer has since re-claimed.commandTimeoutintCommand timeout in seconds.
cancellationTokenCancellationTokenThe cancellation token.
nextAttemptAtDateTimeOffset?Optional per-message next-attempt time (the fine-grained backoff schedule). When provided, the row's
NextAttemptAtcolumn is set so the claim predicate excludes the message until this time elapses. COMPOSED withfloorSecondsrather than replacing it: the column receives the later of the two, so this schedule can only ever defer the next attempt beyond F, never bring it forward.floorSecondsint?Optional failure-anchored visibility floor F, in seconds. It applies on EVERY failure path, including the fine-grained backoff one:
NextAttemptAtis set to at leastSYSUTCDATETIME() + Fon the server clock, so the message is re-claimable only after F — never in the same drain cycle (no hot-loop) and never terminally (at-least-once). F must exceed the poll interval. When both are null, the column is left unchanged.
Remarks
The mark targets the globally-unique outbox Id, which addresses exactly one row, so no tenant
predicate is applied: the drain is cross-tenant infrastructure and must always be able to mark the row
it claimed, regardless of any ambient tenant context. Tenant isolation lives on the write/stage path
(TenantId stamping) and on tenant-facing queries. The Postgres and Oracle providers address this
statement the same way, so the mark behaves identically across providers.
The transition releases the lease (LeasedAt/LeasedBy cleared), matching every other
terminal transition: the failed message is idle, not in-flight, so its computed backoff schedule
governs the next claim and statistics report it as failed rather than leased.
This framework request binds its fixed primitive input and output schema without runtime emit. Replacing a known parameter value is observed at execution; custom parameter metadata, templates and output callbacks are not an extension contract. Custom IDataRequest implementations are unchanged.