Table of Contents

Interface IInMemoryDeduplicator

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

Interface for lightweight in-memory message deduplication without full inbox persistence.

public interface IInMemoryDeduplicator
Extension Methods

Remarks

This provides a simpler alternative to full inbox persistence for scenarios where:

  • Message volume is moderate
  • Duplicate detection window is short (hours, not days)
  • Message loss on restart is acceptable
  • Performance is prioritized over durability

Methods

CleanupExpiredEntriesAsync(CancellationToken)

Removes expired entries from the deduplicator.

Task<int> CleanupExpiredEntriesAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<int>

The number of entries removed.

ClearAsync(CancellationToken)

Clears all tracked message IDs from memory.

Task ClearAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A Task representing the asynchronous operation.

GetStatistics()

Gets current statistics about deduplicator performance and usage.

DeduplicationStatistics GetStatistics()

Returns

DeduplicationStatistics

Statistics about the deduplicator.

IsDuplicateAsync(string, TimeSpan, CancellationToken)

Checks if a message ID has already been processed within the expiry window.

Task<bool> IsDuplicateAsync(string messageId, TimeSpan expiry, CancellationToken cancellationToken)

Parameters

messageId string

The unique identifier of the message.

expiry TimeSpan

How long to remember the message ID.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<bool>

true if the message is a duplicate; otherwise, false.

MarkProcessedAsync(string, TimeSpan, CancellationToken)

Marks a message as processed to prevent duplicate processing.

Task MarkProcessedAsync(string messageId, TimeSpan expiry, CancellationToken cancellationToken)

Parameters

messageId string

The unique identifier of the message.

expiry TimeSpan

How long to remember the message ID.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A Task representing the asynchronous operation.