Table of Contents

Class MarkMessageFailedRequest

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

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

tableName string

The qualified outbox table name.

messageId string

The message ID to mark as failed.

errorMessage string

The error message.

retryCount int

The current retry count.

leasedBy string

BARE 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.

commandTimeout int

Command timeout in seconds.

cancellationToken CancellationToken

The cancellation token.

nextAttemptAt DateTimeOffset?

Optional per-message next-attempt time (the fine-grained backoff schedule). When provided, the row's NextAttemptAt column is set so the claim predicate excludes the message until this time elapses. COMPOSED with floorSeconds rather 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.

floorSeconds int?

Optional failure-anchored visibility floor F, in seconds. It applies on EVERY failure path, including the fine-grained backoff one: NextAttemptAt is set to at least SYSUTCDATETIME() + F on 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.