Class OutboxWorker
Processes the outbox and produces the messages to the target message broker endpoint.
Implements
Inherited Members
Namespace: Silverback.Messaging.Outbound.TransactionalOutbox
Assembly: Silverback.Integration.dll
Syntax
public class OutboxWorker : IOutboxWorker
Constructors
| Improve this doc View sourceOutboxWorker(IServiceScopeFactory, IBrokerCollection, IOutboundRoutingConfiguration, IOutboundLogger<OutboxWorker>, bool, int)
Initializes a new instance of the OutboxWorker class.
Declaration
public OutboxWorker(IServiceScopeFactory serviceScopeFactory, IBrokerCollection brokerCollection, IOutboundRoutingConfiguration routingConfiguration, IOutboundLogger<OutboxWorker> logger, bool enforceMessageOrder, int batchSize)
Parameters
Type | Name | Description |
---|---|---|
IServiceScopeFactory | serviceScopeFactory | The IServiceScopeFactory used to resolve the scoped types. |
IBrokerCollection | brokerCollection | The collection containing the available brokers. |
IOutboundRoutingConfiguration | routingConfiguration | The configured outbound routes. |
IOutboundLogger<OutboxWorker> | logger | |
bool | enforceMessageOrder | Specifies whether the messages must be produced in the same order as they were added to the queue.
If set to |
int | batchSize | The number of messages to be loaded and processed at once. |
Methods
| Improve this doc View sourceProcessQueueAsync(CancellationToken)
Processes the outbox.
Declaration
public Task ProcessQueueAsync(CancellationToken stoppingToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | stoppingToken | A CancellationToken to observe while waiting for the task to complete. |
Returns
Type | Description |
---|---|
Task | A Task that represents the long running operations. |
ProduceMessageAsync(byte[]?, IReadOnlyCollection<MessageHeader>?, IProducerEndpoint, string, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Gets the producer for the specified endpoint and produces the specified message.
Declaration
protected virtual Task ProduceMessageAsync(byte[]? content, IReadOnlyCollection<MessageHeader>? headers, IProducerEndpoint endpoint, string actualEndpointName, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
byte[] | content | The serialized message content (body). |
IReadOnlyCollection<MessageHeader> | headers | The collection of message headers. |
IProducerEndpoint | endpoint | The endpoint to produce to. |
string | actualEndpointName | The actual endpoint name that was resolved for the message. |
Action<IBrokerMessageIdentifier> | onSuccess | The callback to be invoked when the message is successfully produced. |
Action<Exception> | onError | The callback to be invoked when the produce fails. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |