Class InMemoryOutboxStore
An OutboxStore that keeps everything in memory. Queued Statements are lost when the process ends, so use it for tests, or where that is acceptable; use FileOutboxStore otherwise.
public sealed class InMemoryOutboxStore : OutboxStore
- Inheritance
-
InMemoryOutboxStore
- Inherited Members
Remarks
Thread-safe.
Methods
AddAsync(OutboxEntry, CancellationToken)
Adds an entry at the end of the queue, unless an entry with the same Statement id is pending.
public override ValueTask<bool> AddAsync(OutboxEntry entry, CancellationToken cancellationToken)
Parameters
entryOutboxEntryThe entry.
cancellationTokenCancellationTokenCancels the operation.
Returns
GetDeadLetterCountAsync(CancellationToken)
Returns the number of dead letters.
public override ValueTask<int> GetDeadLetterCountAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancels the operation.
Returns
GetDeadLettersAsync(CancellationToken)
Returns the dead letters, oldest first.
public override ValueTask<IReadOnlyList<OutboxDeadLetter>> GetDeadLettersAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancels the operation.
Returns
- ValueTask<IReadOnlyList<OutboxDeadLetter>>
The dead letters.
GetPendingAsync(int, CancellationToken)
Returns the oldest pending entries, in queue order, without removing them.
public override ValueTask<IReadOnlyList<OutboxEntry>> GetPendingAsync(int maxCount, CancellationToken cancellationToken)
Parameters
maxCountintThe largest number of entries to return.
cancellationTokenCancellationTokenCancels the operation.
Returns
- ValueTask<IReadOnlyList<OutboxEntry>>
Up to
maxCountentries; empty when nothing is pending.
GetPendingCountAsync(CancellationToken)
Returns the number of pending entries.
public override ValueTask<int> GetPendingCountAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancels the operation.
Returns
MoveToDeadLettersAsync(OutboxDeadLetter, CancellationToken)
Removes the pending entry with the dead letter's Statement id, if there is one, and stores the dead letter, replacing any dead letter with the same id.
public override ValueTask MoveToDeadLettersAsync(OutboxDeadLetter deadLetter, CancellationToken cancellationToken)
Parameters
deadLetterOutboxDeadLetterThe dead letter.
cancellationTokenCancellationTokenCancels the operation.
Returns
- ValueTask
A task that completes when the change is durable.
RecordFailedAttemptAsync(IReadOnlyCollection<Guid>, string, CancellationToken)
Records a failed send of pending entries: increments Attempts and sets LastError. Ids that are not pending are ignored.
public override ValueTask RecordFailedAttemptAsync(IReadOnlyCollection<Guid> statementIds, string error, CancellationToken cancellationToken)
Parameters
statementIdsIReadOnlyCollection<Guid>The Statement ids.
errorstringA description of the error.
cancellationTokenCancellationTokenCancels the operation.
Returns
- ValueTask
A task that completes when the change is durable.
RemoveAsync(IReadOnlyCollection<Guid>, CancellationToken)
Removes delivered entries. Ids that are not pending are ignored.
public override ValueTask RemoveAsync(IReadOnlyCollection<Guid> statementIds, CancellationToken cancellationToken)
Parameters
statementIdsIReadOnlyCollection<Guid>The Statement ids.
cancellationTokenCancellationTokenCancels the operation.
Returns
- ValueTask
A task that completes when the removal is durable.
RemoveDeadLetterAsync(Guid, CancellationToken)
Deletes a dead letter.
public override ValueTask<bool> RemoveDeadLetterAsync(Guid statementId, CancellationToken cancellationToken)
Parameters
statementIdGuidThe Statement id.
cancellationTokenCancellationTokenCancels the operation.
Returns
RequeueAsync(Guid, CancellationToken)
Moves a dead letter back to the end of the queue as a pending entry with no failed attempts. If an entry with the same id is already pending, the dead letter is only removed.
public override ValueTask<bool> RequeueAsync(Guid statementId, CancellationToken cancellationToken)
Parameters
statementIdGuidThe Statement id.
cancellationTokenCancellationTokenCancels the operation.