Interface DeadLetterMessage<T>

Type Parameters:
T - payload type
All Superinterfaces:
Message<T>

public interface DeadLetterMessage<T> extends Message<T>
Immutable message routed to a logical dead-letter channel.

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 Details

    • SOURCE_CHANNEL_HEADER

      static final String SOURCE_CHANNEL_HEADER
      Reserved common header containing the source channel.
      See Also:
    • ATTEMPTS_HEADER

      static final String ATTEMPTS_HEADER
      Reserved common header containing the total delivery attempts.
      See Also:
    • FAILURE_TYPE_METADATA

      static final String 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

      static final String 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 message
      sourceChannel - source channel
      attempts - total delivery attempts
      failure - processing failure
      Returns:
      immutable dead-letter message
      Throws:
      NullPointerException - if originalMessage, sourceChannel, or failure is null
      IllegalArgumentException - if sourceChannel is blank or attempts is less than one
    • originalMessage

      Message<T> originalMessage()
      Original extendable message envelope.
      Returns:
      original message
    • sourceChannel

      String sourceChannel()
      Source logical channel.
      Returns:
      source channel
    • attempts

      int attempts()
      Total delivery attempts, including the initial delivery.
      Returns:
      delivery attempts
    • failureType

      default String failureType()
      Processing failure class name.

      This local diagnostic is stored under FAILURE_TYPE_METADATA in Message.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

      default String failureMessage()
      Processing failure message.

      This local diagnostic is stored under FAILURE_MESSAGE_METADATA in Message.localMetadata(). It may contain sensitive data and may be arbitrarily long, so it must be explicitly redacted and bounded before publication. A message returned by create(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