Class MessageHeaderUtils

java.lang.Object
io.awspring.cloud.sqs.MessageHeaderUtils

public class MessageHeaderUtils extends Object
Utility class for extracting MessageHeaders from a Message.
Since:
3.0
Author:
Tomaz Fernandes
  • Method Details

    • getId

      public static String getId(Message<?> message)
      Return the message's ID as {@link String].
      Parameters:
      message - the message.
      Returns:
      the ID.
    • getId

      public static <T> String getId(Collection<Message<T>> messages)
      Return the messages' ID as a concatenated {@link String].
      Parameters:
      messages - the messages.
      Returns:
      the IDs.
    • getHeader

      public static <T> T getHeader(Message<?> message, String headerName, Class<T> classToCast)
      Get the specified header or throw an exception if such header is not present.
      Type Parameters:
      T - the class type.
      Parameters:
      message - the message.
      headerName - the header name.
      classToCast - the class to which the header should be cast to.
      Returns:
      the header value.
    • getHeader

      public static <T, U> Collection<T> getHeader(Collection<Message<U>> messages, String headerName, Class<T> classToCast)
      Get the specified header or throw an exception if such header is not present.
      Type Parameters:
      T - the header class type.
      U - the messages payload class type.
      Parameters:
      messages - the messages.
      headerName - the header name.
      classToCast - the class to which the header should be cast to.
      Returns:
      the header value.
    • getHeaderAsString

      public static String getHeaderAsString(Message<?> message, String headerName)
      Get the provided header as String or throw if not present.
      Parameters:
      message - the message.
      headerName - the header name.
      Returns:
      the header value.