Class SqsMessageIdResolver

java.lang.Object
io.awspring.cloud.sqs.support.converter.SqsMessageIdResolver

public final class SqsMessageIdResolver extends Object
Utility class for resolving SQS message IDs. Consolidates UUID validation, conversion, and fail-fast logic used by both SqsHeaderMapper and SqsTemplate.
Since:
4.1.0
Author:
Jeongmin Kim
  • Method Details

    • resolveAndAddMessageId

      public static MessageHeaders resolveAndAddMessageId(String messageId, MessageHeaders headers, boolean convertMessageIdToUuid)
      Resolve the message ID and add it to the provided headers. The raw message ID is always stored in the SqsHeaders.SQS_RAW_MESSAGE_ID_HEADER header.

      If the message ID is a valid UUID, it is used directly. If not, and convertMessageIdToUuid is true, a MessagingException is thrown with instructions to disable UUID conversion. If convertMessageIdToUuid is false, a deterministic UUID is generated from the raw message ID.

      Parameters:
      messageId - the raw message ID from SQS.
      headers - the existing message headers.
      convertMessageIdToUuid - whether to enforce UUID message IDs.
      Returns:
      the resolved MessageHeaders with the message ID set.
      Throws:
      MessagingException - if the message ID is not a valid UUID and conversion is enabled.
    • configureMessageIdResolution

      public static void configureMessageIdResolution(MessagingMessageConverter<software.amazon.awssdk.services.sqs.model.Message> converter, boolean convertMessageIdToUuid)
      Configure message ID resolution on the given converter. If the converter is an AbstractMessagingMessageConverter with a SqsHeaderMapper, sets the convertMessageIdToUuid flag on it.
      Parameters:
      converter - the messaging message converter.
      convertMessageIdToUuid - whether to enforce UUID message IDs.