Class InMemoryOutbox
An outbound queue persisted in memory. Note that writing in the queue is thread-safe but reading is not. Implements both IOutboxWriter and IOutboxReader.
Inherited Members
Namespace: Silverback.Messaging.Outbound.TransactionalOutbox.Repositories
Assembly: Silverback.Integration.dll
Syntax
public class InMemoryOutbox : TransactionalList<OutboxStoredMessage>, IOutboxWriter, IOutboxReader
Constructors
| Improve this doc View sourceInMemoryOutbox(TransactionalListSharedItems<OutboxStoredMessage>)
Initializes a new instance of the InMemoryOutbox class.
Declaration
public InMemoryOutbox(TransactionalListSharedItems<OutboxStoredMessage> sharedItems)
Parameters
Type | Name | Description |
---|---|---|
TransactionalListSharedItems<OutboxStoredMessage> | sharedItems | The messages shared between the instances of this repository. |
Methods
| Improve this doc View sourceAcknowledgeAsync(OutboxStoredMessage)
Called after the message has been successfully produced to remove it from the outbox.
Declaration
public Task AcknowledgeAsync(OutboxStoredMessage outboxMessage)
Parameters
Type | Name | Description |
---|---|---|
OutboxStoredMessage | outboxMessage | The message that was processed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the result of the asynchronous operation. |
AcknowledgeAsync(IEnumerable<OutboxStoredMessage>)
Called after the message has been successfully produced to remove it from the outbox.
Declaration
public Task AcknowledgeAsync(IEnumerable<OutboxStoredMessage> outboxMessages)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<OutboxStoredMessage> | outboxMessages | The messages that have been processed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the result of the asynchronous operation. |
GetLengthAsync()
Returns the total number of messages in the outbox.
Declaration
public Task<int> GetLengthAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | A System.Threading.Tasks.Task<TResult> representing the asynchronous operation. The task result contains the number of messages in the outbox. |
GetMaxAgeAsync()
Gets a System.TimeSpan representing the time elapsed since the oldest message currently in the outbox was written.
Declaration
public Task<TimeSpan> GetMaxAgeAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.TimeSpan> | The age of the oldest message. |
ReadAsync(Int32)
Reads the specified number of messages from the outbox (according to the FIFO rule). The operation must be acknowledged for the messages to be removed.
Declaration
public Task<IReadOnlyCollection<OutboxStoredMessage>> ReadAsync(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | The number of items to be dequeued. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<OutboxStoredMessage>> | A System.Threading.Tasks.Task representing the result of the asynchronous operation. The task result contains the collection of OutboxStoredMessage. |
RetryAsync(OutboxStoredMessage)
Called when an error occurs producing the message to re-enqueue it and retry later on.
Declaration
public Task RetryAsync(OutboxStoredMessage outboxMessage)
Parameters
Type | Name | Description |
---|---|---|
OutboxStoredMessage | outboxMessage | The message that was processed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the result of the asynchronous operation. |
RetryAsync(IEnumerable<OutboxStoredMessage>)
Called when an error occurs producing the message to re-enqueue it and retry later on.
Declaration
public Task RetryAsync(IEnumerable<OutboxStoredMessage> outboxMessages)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<OutboxStoredMessage> | outboxMessages | The messages that have been processed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the result of the asynchronous operation. |
WriteAsync(Object, Byte[], IReadOnlyCollection<MessageHeader>, String, String)
Adds the message contained in the specified envelope to the outbox.
Declaration
public Task WriteAsync(object message, byte[] messageBytes, IReadOnlyCollection<MessageHeader> headers, string endpointName, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | The message to be delivered. |
System.Byte[] | messageBytes | The actual serialized message to be delivered. |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | The message headers. |
System.String | endpointName | The name of the configured endpoint to produce to. |
System.String | actualEndpointName | The actual endpoint to produce to. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |