Class CachingSequencedDeadLetterQueue<M extends Message>

java.lang.Object
org.axonframework.messaging.eventhandling.deadletter.CachingSequencedDeadLetterQueue<M>
Type Parameters:
M - The type of Message contained in the dead letters within this queue.
All Implemented Interfaces:
SequencedDeadLetterQueue<M>

@Internal public class CachingSequencedDeadLetterQueue<M extends Message> extends Object implements SequencedDeadLetterQueue<M>
A decorator for SequencedDeadLetterQueue that adds per-segment caching of sequence identifiers to optimize contains(Object, ProcessingContext) lookups. This is particularly important for high-throughput event processing where checking if an event's sequence is already dead-lettered should be as fast as possible.

Each Segment gets its own independent SequenceIdentifierCache, obtained from the ProcessingContext. When a segment is released, only that segment's cache is removed via invalidateCache(ProcessingContext), leaving other segments' caches intact.

If no segment is available in the ProcessingContext (or the context is null), operations delegate directly to the underlying queue without caching.

Thread-safety note: This class is not thread-safe when performing operations for the same sequence identifier concurrently. It is designed for internal use by DeadLetteringEventHandlingComponent, where operations on a given sequence identifier are already serialized by the upstream SequencingEventHandlingComponent. Different segments can operate concurrently without interference. External synchronization must be provided if this class is used in other contexts where concurrent access to the same sequence identifier is possible.

Since:
5.1.0
Author:
Mateusz Nowak
See Also: