Record Class DeadLetter
- Record Components:
message- the message that was given up on; nevernullreason- why it was given up on, in a form a human reads; nevernullrecipientId- the agent the message was addressed to, ornullfor a topic delivery, where no single agent was the intended recipientattempts- how many times a handler was invoked for this message; at least 1deadLetteredAt- when the framework gave up
A dead letter is a record of a decision already taken: the message is not queued for another attempt, and recording it changes nothing about its fate. It exists so that the fate is legible — before this type, a message lost on the in-memory transport left one log line, and one dead-lettered on Redis left an entry in a stream no API could read.
attempts counts how many times a handler was actually invoked for this message.
On a transport with redelivery it is the exhausted attempt limit; on one without, it is
1. That is a fact about the transport, not a placeholder — a dead letter with one
attempt says the message was never retried because retrying it was never possible.
- Since:
- 0.32.0
-
Constructor Summary
ConstructorsConstructorDescriptionDeadLetter(Message message, String reason, String recipientId, int attempts, Instant deadLetteredAt) Canonical constructor. -
Method Summary
Modifier and TypeMethodDescriptionintattempts()Returns the value of theattemptsrecord component.Returns the value of thedeadLetteredAtrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.message()Returns the value of themessagerecord component.static DeadLetterRecords a message given up on after a single attempt, which is the only outcome a transport without redelivery can produce.static DeadLetterRecords a message given up on afterattemptshandler invocations.reason()Returns the value of thereasonrecord component.Returns the value of therecipientIdrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
DeadLetter
public DeadLetter(Message message, String reason, String recipientId, int attempts, Instant deadLetteredAt) Canonical constructor.- Throws:
NullPointerException- ifmessage,reasonordeadLetteredAtisnullIllegalArgumentException- ifattemptsis less than 1
-
-
Method Details
-
of
Records a message given up on after a single attempt, which is the only outcome a transport without redelivery can produce.The reason is taken from the failure's own message where it has one, and from its type where it does not — an exception with a null message is common enough that
"null"would otherwise be the most frequent reason in the queue.- Parameters:
message- the message that failed; must not benullrecipientId- the agent it was addressed to, ornullfor a topic deliverycause- the failure; must not benull- Returns:
- the dead letter, timestamped now; never
null
-
of
Records a message given up on afterattemptshandler invocations.- Parameters:
message- the message that failed; must not benullrecipientId- the agent it was addressed to, ornullfor a topic deliverycause- the failure; must not benullattempts- how many times a handler was invoked; at least 1- Returns:
- the dead letter, timestamped now; never
null
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
reason
Returns the value of thereasonrecord component.- Returns:
- the value of the
reasonrecord component
-
recipientId
Returns the value of therecipientIdrecord component.- Returns:
- the value of the
recipientIdrecord component
-
attempts
public int attempts()Returns the value of theattemptsrecord component.- Returns:
- the value of the
attemptsrecord component
-
deadLetteredAt
Returns the value of thedeadLetteredAtrecord component.- Returns:
- the value of the
deadLetteredAtrecord component
-