Table of Contents

Class OutboxWorker

Namespace
Silverback.Messaging.Producing.TransactionalOutbox
Assembly
Silverback.Integration.dll

Processes the outbox and produces the messages to the target message broker endpoint.

public sealed class OutboxWorker : IOutboxWorker, IDisposable
Inheritance
OutboxWorker
Implements
Inherited Members

Constructors

OutboxWorker(OutboxWorkerSettings, IOutboxReader, IProducerCollection, ISilverbackLogger<OutboxWorker>)

Initializes a new instance of the OutboxWorker class.

public OutboxWorker(OutboxWorkerSettings settings, IOutboxReader outboxReader, IProducerCollection producers, ISilverbackLogger<OutboxWorker> logger)

Parameters

settings OutboxWorkerSettings

The worker settings.

outboxReader IOutboxReader

The IOutboxReader to be used to retrieve the pending messages.

producers IProducerCollection

The IProducerCollection.

logger ISilverbackLogger<OutboxWorker>

The ISilverbackLogger<TCategoryName>.

Methods

Dispose()

public void Dispose()

GetLengthAsync()

Returns the total number of messages in the outbox.

public Task<int> GetLengthAsync()

Returns

Task<int>

A Task<TResult> representing the asynchronous operation. The task result contains the number of messages in the outbox.

ProcessOutboxAsync(CancellationToken)

Processes the outbox relaying the stored messages.

public Task<bool> ProcessOutboxAsync(CancellationToken stoppingToken)

Parameters

stoppingToken CancellationToken

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

Returns

Task<bool>

A Task<TResult> representing the asynchronous operation. The task result contains a value indicating whether the outbox contained at least 1 message, and it was successfully processed. The caller should ideally keep invoking this method in a loop, until false is returned.