Class OutboxStoreExtensions
Extension methods for IOutboxStore.
public static class OutboxStoreExtensions
- Inheritance
-
OutboxStoreExtensions
- Inherited Members
Methods
MarkBatchFailedAsync(IOutboxStore, IReadOnlyList<string>, string, int, string, CancellationToken)
Marks a batch of messages as failed UNDER A CLAIM, reporting per message whether the store applied it.
public static ValueTask<IReadOnlyList<OutboxCompletionOutcome>> MarkBatchFailedAsync(this IOutboxStore store, IReadOnlyList<string> messageIds, string reason, int retryCount, string claimIdentity, CancellationToken cancellationToken)
Parameters
storeIOutboxStoreThe outbox store. Must expose IClaimScopedOutboxStore.
messageIdsIReadOnlyList<string>The messages to complete.
reasonstringThe failure reason recorded against each message.
retryCountintThe attempt count recorded against each message.
claimIdentitystringThe claim the caller holds and is reporting under.
cancellationTokenCancellationTokenA cancellation token.
Returns
- ValueTask<IReadOnlyList<OutboxCompletionOutcome>>
One outcome per message id, in the same order. Test for Applied BY NAME; every other value, defined or not, means the store did not apply that message's completion.
Remarks
Prefer this over the unscoped overload whenever the caller holds a claim. The unscoped one completes on MarkFailedAsync(string, string, int, CancellationToken) with no ownership check, so a caller whose claim has lapsed — because its dispatch hung past the reservation window and a later cycle re-claimed the message — has its report accepted anyway, and overwrites a decision it is no longer entitled to make.
It deliberately does NOT take the batch fast path, and that is a capability limit rather than an oversight. MarkBatchFailedAsync(IReadOnlyList<string>, string, int, CancellationToken) returns no value and carries no claim term, so it can neither honour a claim nor report a refusal; routing a claim-scoped completion through it would discard the guarantee this overload exists to provide. Until that member can express an outcome, per-message completion is the only honest implementation, and the cost is stated here rather than hidden.
Outcomes are per message because a lost claim is ROW-scoped. One message being re-claimed says nothing about the others: the caller still owns the rest of the batch and must still complete them. A single aggregate result would force the caller to treat one re-claimed row as a whole-batch failure, which strands messages it still holds.
Exceptions
- NotSupportedException
Thrown when
storedoes not expose IClaimScopedOutboxStore. A caller holding a claim cannot be silently served an unscoped completion: that is the defect this overload exists to remove, and returning a success-shaped answer would reintroduce it one layer up.
MarkBatchFailedAsync(IOutboxStore, IReadOnlyList<string>, string, int, CancellationToken)
Marks a batch of messages as failed.
public static ValueTask MarkBatchFailedAsync(this IOutboxStore store, IReadOnlyList<string> messageIds, string reason, int retryCount, CancellationToken cancellationToken)
Parameters
storeIOutboxStoremessageIdsIReadOnlyList<string>reasonstringretryCountintcancellationTokenCancellationToken
Returns
MarkBatchSentAsync(IOutboxStore, IReadOnlyList<string>, CancellationToken)
Marks a batch of messages as successfully sent.
public static ValueTask MarkBatchSentAsync(this IOutboxStore store, IReadOnlyList<string> messageIds, CancellationToken cancellationToken)
Parameters
storeIOutboxStoremessageIdsIReadOnlyList<string>cancellationTokenCancellationToken
Returns
TryMarkSentAndReceivedAsync(IOutboxStore, string, InboxEntry, CancellationToken)
Atomically marks message as sent and creates the inbox entry in one transaction, so a redelivery is skipped rather than reprocessed (effectively-once processing; delivery remains at-least-once).
public static ValueTask<bool> TryMarkSentAndReceivedAsync(this IOutboxStore store, string messageId, InboxEntry inboxEntry, CancellationToken cancellationToken)
Parameters
storeIOutboxStoremessageIdstringinboxEntryInboxEntrycancellationTokenCancellationToken