Table of Contents

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

outboxSettings OutboxSettings

The settings of the outbox to clear.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

ClearAsync(CancellationToken)

Removes all the pending messages from all the outboxes, without producing them.

ValueTask ClearAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

outboxSettings OutboxSettings

The settings of the outbox to read.

cancellationToken CancellationToken

A 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

cancellationToken CancellationToken

A 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

outboxSettings OutboxSettings

The settings of the outbox to read.

cancellationToken CancellationToken

A 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

cancellationToken CancellationToken

A 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

outboxSettings OutboxSettings

The settings of the outbox to check.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask<bool>

A ValueTask<TResult> representing the asynchronous operation. The task result contains true if the outbox is empty, otherwise false.

IsEmptyAsync(CancellationToken)

Checks whether all the outboxes are empty.

ValueTask<bool> IsEmptyAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask<bool>

A ValueTask<TResult> representing the asynchronous operation. The task result contains true if the outboxes are empty, otherwise false.

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

outboxSettings OutboxSettings

The settings of the outbox.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the running batch to complete. The cancellation only stops the wait: the worker stays paused until ResumeWorker is called.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

cancellationToken CancellationToken

A 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 ResumeWorker is called.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

outboxSettings OutboxSettings

The settings of the outbox to process.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

outboxSettings OutboxSettings

The 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

outboxSettings OutboxSettings

The settings of the outbox to wait for.

timeout TimeSpan?

The time to wait for the outbox to be empty. The default is 30 seconds.

Returns

ValueTask

A ValueTask that completes when the outbox is empty.

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

outboxSettings OutboxSettings

The settings of the outbox to wait for.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask

A ValueTask that completes when the outbox is empty.

Exceptions

OperationCanceledException

The cancellationToken was 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

timeout TimeSpan?

The time to wait for the outboxes to be empty. The default is 30 seconds.

Returns

ValueTask

A ValueTask that completes when the outboxes are empty.

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

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

ValueTask

A ValueTask that completes when the outboxes are empty.

Exceptions

OperationCanceledException

The cancellationToken was canceled before the outboxes were emptied.