Class EfInboxStore
Entity Framework Core implementation of IInboxStore and ICleanupStore. Relies on a unique database constraint on (MessageId, ConsumerTypeName) to provide atomic reservations, and supports both at‑most‑once and at‑least‑once delivery via ChaparInboxOptions.
Inherited Members
Namespace: Chapar.Inbox.EntityFrameworkCore.Stores
Assembly: Chapar.Inbox.EntityFrameworkCore.dll
Syntax
public sealed class EfInboxStore : IInboxStore, ICleanupStore
Constructors
| Edit this page View SourceEfInboxStore(IChaparDbContext, IOptions<ChaparInboxOptions>?)
Initializes a new instance of the EfInboxStore class.
Declaration
public EfInboxStore(IChaparDbContext dbContext, IOptions<ChaparInboxOptions>? options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IChaparDbContext | dbContext | The IChaparDbContext used to access the inbox table. |
| IOptions<ChaparInboxOptions> | options | The inbox configuration options (optional; falls back to defaults). |
Methods
| Edit this page View SourceDeleteProcessedAsync(DateTime, CancellationToken)
Deletes all processed records older than the specified date. Returns the number of deleted records.
Declaration
public Task<int> DeleteProcessedAsync(DateTime olderThan, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | olderThan | Cutoff date; records processed before this will be deleted. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<int> | Number of deleted records. |
MarkAsProcessedAsync(InboxMessage, CancellationToken)
Marks a previously reserved message as completely processed. Called only after the handler has finished without exception.
Declaration
public Task<bool> MarkAsProcessedAsync(InboxMessage message, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| InboxMessage | message | The inbox message record that should be updated. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
|
TryReserveAsync(string, string, CancellationToken)
Attempts to atomically reserve an incoming message for processing.
When the method returns true the caller is the exclusive processor of the message;
when it returns false the message has already been reserved by another consumer.
Declaration
public Task<bool> TryReserveAsync(string messageId, string consumerTypeName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | messageId | The unique identifier of the incoming message. |
| string | consumerTypeName | The fully qualified type name of the consumer that will handle the message. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
|