Interface IOutboxTestingHelper
- Namespace
- Silverback.Testing
- Assembly
- Silverback.Integration.Testing.dll
Exposes the helper methods that simplify testing the applications using the transactional outbox.
public interface IOutboxTestingHelper
Methods
ClearAsync(OutboxSettings, CancellationToken)
Removes all the pending messages from the specified outbox, without producing them.
ValueTask ClearAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken = default)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to clear.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
ClearAsync(CancellationToken)
Removes all the pending messages from all the outboxes, without producing them.
ValueTask ClearAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
GetLengthAsync(OutboxSettings, CancellationToken)
Returns the number of messages that are currently pending in the specified outbox.
ValueTask<int> GetLengthAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken = default)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to read.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<int>
A ValueTask<TResult> representing the asynchronous operation. The task result contains the number of pending messages.
GetLengthAsync(CancellationToken)
Returns the number of messages that are currently pending in all the outboxes.
ValueTask<int> GetLengthAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<int>
A ValueTask<TResult> representing the asynchronous operation. The task result contains the number of pending messages.
GetMessagesAsync(OutboxSettings, CancellationToken)
Returns the messages that are currently pending in the specified outbox, without removing them.
ValueTask<IReadOnlyList<OutboxMessage>> GetMessagesAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken = default)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to read.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<IReadOnlyList<OutboxMessage>>
A ValueTask<TResult> representing the asynchronous operation. The task result contains the pending messages.
GetMessagesAsync(CancellationToken)
Returns the messages that are currently pending in all the outboxes, without removing them.
ValueTask<IReadOnlyList<OutboxMessage>> GetMessagesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<IReadOnlyList<OutboxMessage>>
A ValueTask<TResult> representing the asynchronous operation. The task result contains the pending messages.
IsEmptyAsync(OutboxSettings, CancellationToken)
Checks whether the specified outbox is empty.
ValueTask<bool> IsEmptyAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken = default)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to check.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<bool>
A ValueTask<TResult> representing the asynchronous operation. The task result contains
trueif the outbox is empty, otherwisefalse.
IsEmptyAsync(CancellationToken)
Checks whether all the outboxes are empty.
ValueTask<bool> IsEmptyAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<bool>
A ValueTask<TResult> representing the asynchronous operation. The task result contains
trueif the outboxes are empty, otherwisefalse.
PauseWorkerAsync(OutboxSettings, CancellationToken)
Stops the outbox worker processing the specified outbox from processing it at regular intervals. The returned ValueTask completes when the worker is not processing the outbox anymore.
ValueTask PauseWorkerAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken = default)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the running batch to complete. The cancellation only stops the wait: the worker stays paused until
ResumeWorkeris called.
Returns
Exceptions
- InvalidOperationException
No outbox worker is registered for the specified outbox.
PauseWorkerAsync(CancellationToken)
Stops the registered outbox workers from processing the outboxes at regular intervals. The returned ValueTask completes when no worker is processing the outbox anymore.
ValueTask PauseWorkerAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the running batch to complete. The cancellation only stops the wait: the workers paused so far stay paused until
ResumeWorkeris called.
Returns
Exceptions
- InvalidOperationException
No outbox worker is registered.
ProcessAsync(OutboxSettings, CancellationToken)
Runs the outbox worker processing the specified outbox right away, until the outbox is empty.
ValueTask ProcessAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken = default)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to process.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Remarks
The distributed lock is bypassed and the exceptions are propagated to the caller.
Exceptions
- InvalidOperationException
No outbox worker is registered for the specified outbox.
ProcessAsync(CancellationToken)
Runs the registered outbox workers right away, until the outboxes are empty. This is especially useful in combination with the
UseManualOutboxWorker configuration.
ValueTask ProcessAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Remarks
The distributed lock is bypassed and the exceptions are propagated to the caller.
Exceptions
- InvalidOperationException
No outbox worker is registered.
ResumeWorker()
Resumes the processing of the outboxes at regular intervals, after PauseWorkerAsync. It resumes the workers suspended
by UseManualOutboxWorker as well.
void ResumeWorker()
Exceptions
- InvalidOperationException
No outbox worker is registered.
ResumeWorker(OutboxSettings)
Resumes the processing of the specified outbox at regular intervals, after PauseWorkerAsync. It resumes the worker
suspended by UseManualOutboxWorker as well.
void ResumeWorker(OutboxSettings outboxSettings)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox.
Exceptions
- InvalidOperationException
No outbox worker is registered for the specified outbox.
WaitUntilEmptyAsync(OutboxSettings, TimeSpan?)
Returns a ValueTask that completes when the specified outbox has been emptied, regardless of whether it's being drained by a worker.
ValueTask WaitUntilEmptyAsync(OutboxSettings outboxSettings, TimeSpan? timeout = null)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to wait for.
timeoutTimeSpan?The time to wait for the outbox to be empty. The default is 30 seconds.
Returns
Exceptions
- TimeoutException
The timeout elapsed before the outbox was emptied.
WaitUntilEmptyAsync(OutboxSettings, CancellationToken)
Returns a ValueTask that completes when the specified outbox has been emptied, regardless of whether it's being drained by a worker.
ValueTask WaitUntilEmptyAsync(OutboxSettings outboxSettings, CancellationToken cancellationToken)
Parameters
outboxSettingsOutboxSettingsThe settings of the outbox to wait for.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
The
cancellationTokenwas canceled before the outbox was emptied.
WaitUntilEmptyAsync(TimeSpan?)
Returns a ValueTask that completes when the outboxes being drained by a registered and not paused worker have been emptied.
ValueTask WaitUntilEmptyAsync(TimeSpan? timeout = null)
Parameters
timeoutTimeSpan?The time to wait for the outboxes to be empty. The default is 30 seconds.
Returns
Exceptions
- TimeoutException
The timeout elapsed before the outboxes were emptied.
WaitUntilEmptyAsync(CancellationToken)
Returns a ValueTask that completes when the outboxes being drained by a registered and not paused worker have been emptied.
ValueTask WaitUntilEmptyAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
The
cancellationTokenwas canceled before the outboxes were emptied.