Class InMemoryDeadLetterQueue
- All Implemented Interfaces:
DeadLetterQueue
DeadLetterQueue holding a bounded window of recent entries in memory.
The default for a runtime that has not been given a durable one. It is a window, not an
archive: past capacity() entries the oldest are evicted, and nothing survives a
restart. totalRecorded() is what tells you whether eviction has happened, so that a
full window is distinguishable from a quiet one.
Those limits are the honest shape for this transport. The in-memory dispatcher does not redeliver, so a dead letter here is a message that is already lost; keeping it is what makes the loss visible, and keeping it forever would only trade one leak for another.
- Since:
- 0.32.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intEntries kept when no capacity is given. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a queue holdingDEFAULT_CAPACITYentries.InMemoryDeadLetterQueue(int capacity) Creates a queue holding at mostcapacityentries. -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()Returns how many entries this queue keeps before evicting the oldest.recent(int limit) Returns the most recently dead-lettered messages, newest first.voidrecord(DeadLetter deadLetter) Records a message the framework has given up on.longReturns how many entries have ever been recorded, including those since evicted.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYEntries kept when no capacity is given.- See Also:
-
-
Constructor Details
-
InMemoryDeadLetterQueue
public InMemoryDeadLetterQueue()Creates a queue holdingDEFAULT_CAPACITYentries. -
InMemoryDeadLetterQueue
public InMemoryDeadLetterQueue(int capacity) Creates a queue holding at mostcapacityentries.- Parameters:
capacity- the number of entries to keep; must be positive- Throws:
IllegalArgumentException- ifcapacityis not positive
-
-
Method Details
-
record
Description copied from interface:DeadLetterQueueRecords a message the framework has given up on.Called from a delivery path that has already failed, so it must not throw: an implementation that cannot store the entry logs and returns rather than turning a lost message into a second failure on top of it.
- Specified by:
recordin interfaceDeadLetterQueue- Parameters:
deadLetter- what was given up on and why; must not benull
-
recent
Description copied from interface:DeadLetterQueueReturns the most recently dead-lettered messages, newest first.What "recent" reaches depends on the implementation and is a property worth knowing before relying on it: an in-memory queue holds a bounded window and forgets on restart, while one backed by a durable stream reaches as far back as that stream is retained.
- Specified by:
recentin interfaceDeadLetterQueue- Parameters:
limit- the maximum number of entries to return; must be positive- Returns:
- the entries, newest first, at most
limitof them; nevernull, possibly empty
-
capacity
public int capacity()Returns how many entries this queue keeps before evicting the oldest.- Returns:
- the capacity; always positive
-
totalRecorded
public long totalRecorded()Returns how many entries have ever been recorded, including those since evicted.Compare it with the size of
recent(int)to tell a window that has overflowed from one that has not.- Returns:
- the total ever recorded; never negative
-