Package io.awspring.cloud.sqs
Class MessageHeaderUtils
java.lang.Object
io.awspring.cloud.sqs.MessageHeaderUtils
Utility class for extracting
MessageHeaders
from a Message
.- Since:
- 3.0
- Author:
- Tomaz Fernandes
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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.static <T> T
Get the specified header or throw an exception if such header is not present.static String
getHeaderAsString
(Message<?> message, String headerName) Get the provided header asString
or throw if not present.static <T> String
getId
(Collection<Message<T>> messages) Return the messages' ID as a concatenated {@link String].static String
Return the message's ID as {@link String].
-
Method Details
-
getId
Return the message's ID as {@link String].- Parameters:
message
- the message.- Returns:
- the ID.
-
getId
Return the messages' ID as a concatenated {@link String].- Parameters:
messages
- the messages.- Returns:
- the IDs.
-
getHeader
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
Get the provided header asString
or throw if not present.- Parameters:
message
- the message.headerName
- the header name.- Returns:
- the header value.
-