Interface DeadLetterMessage<T>
- Type Parameters:
T- payload type
- All Superinterfaces:
Message<T>
The failure type and message are local diagnostic data in Message.localMetadata(). Connectors must never map local
metadata to a transport. Applications that intentionally publish failure diagnostics must first redact and bound
them, then explicitly promote them to portable headers.
Every implementation must provide text values under FAILURE_TYPE_METADATA and
FAILURE_MESSAGE_METADATA in its local metadata.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringReserved common header containing the total delivery attempts.static final StringRequired reserved local metadata containing the processing failure message.static final StringRequired reserved local metadata containing the processing failure class.static final StringReserved common header containing the source channel. -
Method Summary
Modifier and TypeMethodDescriptionintattempts()Total delivery attempts, including the initial delivery.static <T> DeadLetterMessage<T> create(Message<T> originalMessage, String sourceChannel, int attempts, RuntimeException failure) Create a dead-letter message.default StringProcessing failure message.default StringProcessing failure class name.Original extendable message envelope.Source logical channel.Methods inherited from interface Message
entity, header, headers, headerValue, localMetadataModifier and TypeMethodDescriptionentity()Payload.Last portable text header value with an exact name.headers()Ordered portable headers.default Optional<MessageHeaderValue> headerValue(String name) Last portable header value with an exact name.default MessageMetadataMetadata local to this message envelope.
-
Field Details
-
SOURCE_CHANNEL_HEADER
Reserved common header containing the source channel.- See Also:
-
ATTEMPTS_HEADER
Reserved common header containing the total delivery attempts.- See Also:
-
FAILURE_TYPE_METADATA
Required reserved local metadata containing the processing failure class.Local metadata is never transported implicitly by a connector.
- See Also:
-
FAILURE_MESSAGE_METADATA
Required reserved local metadata containing the processing failure message.Local metadata is never transported implicitly by a connector.
- See Also:
-
-
Method Details
-
create
static <T> DeadLetterMessage<T> create(Message<T> originalMessage, String sourceChannel, int attempts, RuntimeException failure) Create a dead-letter message.- Type Parameters:
T- payload type- Parameters:
originalMessage- original messagesourceChannel- source channelattempts- total delivery attemptsfailure- processing failure- Returns:
- immutable dead-letter message
- Throws:
NullPointerException- iforiginalMessage,sourceChannel, orfailureisnullIllegalArgumentException- ifsourceChannelis blank orattemptsis less than one
-
originalMessage
-
sourceChannel
-
attempts
int attempts()Total delivery attempts, including the initial delivery.- Returns:
- delivery attempts
-
failureType
Processing failure class name.This local diagnostic is stored under
FAILURE_TYPE_METADATAinMessage.localMetadata(). It may expose implementation details and must be explicitly sanitized before publication.- Returns:
- failure class name
- Throws:
IllegalStateException- if the required local metadata is missing or is not a text value
-
failureMessage
Processing failure message.This local diagnostic is stored under
FAILURE_MESSAGE_METADATAinMessage.localMetadata(). It may contain sensitive data and may be arbitrarily long, so it must be explicitly redacted and bounded before publication. A message returned bycreate(Message, String, int, RuntimeException)stores an empty string when the processing exception has no message.- Returns:
- failure message, or an empty string when the processing exception had no message
- Throws:
IllegalStateException- if the required local metadata is missing or is not a text value
-