Class KafkaMessageHeaderAccessor
java.lang.Object
org.springframework.messaging.support.MessageHeaderAccessor
org.springframework.kafka.support.KafkaMessageHeaderAccessor
A header accessor to provide convenient access to certain headers in a
type specific manner.
- Since:
- 3.0.10
- Author:
- Gary Russell
-
Field Summary
Fields inherited from class org.springframework.messaging.support.MessageHeaderAccessor
DEFAULT_CHARSET
-
Constructor Summary
ConstructorDescriptionKafkaMessageHeaderAccessor
(Message<?> message) Construct an instance for the provided message. -
Method Summary
Modifier and TypeMethodDescriptionprotected MessageHeaderAccessor
createAccessor
(Message<?> message) int
Access the header value when the blocking delivery attempt header is present.<T> T
Get a header value with a specific type.int
When using non-blocking retries, get the delivery attempt header value as an int.static KafkaMessageHeaderAccessor
Create an instance from the payload and headers of the given Message.Methods inherited from class org.springframework.messaging.support.MessageHeaderAccessor
copyHeaders, copyHeadersIfAbsent, getAccessor, getAccessor, getAccessor, getContentType, getDetailedLogMessage, getDetailedPayloadLogMessage, getErrorChannel, getHeader, getId, getMessageHeaders, getMutableAccessor, getReplyChannel, getShortLogMessage, getShortPayloadLogMessage, getTimestamp, isModified, isMutable, isReadableContentType, isReadOnly, removeHeader, removeHeaders, setContentType, setErrorChannel, setErrorChannelName, setHeader, setHeaderIfAbsent, setImmutable, setLeaveMutable, setModified, setReplyChannel, setReplyChannelName, toMap, toMessageHeaders, toString, verifyType
-
Constructor Details
-
KafkaMessageHeaderAccessor
Construct an instance for the provided message.- Parameters:
message
- the message.
-
-
Method Details
-
getBlockingRetryDeliveryAttempt
public int getBlockingRetryDeliveryAttempt()Access the header value when the blocking delivery attempt header is present.- Returns:
- The decoded header value if the header is present.
- Throws:
IllegalStateException
- if the header is not present.- See Also:
-
getNonBlockingRetryDeliveryAttempt
public int getNonBlockingRetryDeliveryAttempt()When using non-blocking retries, get the delivery attempt header value as an int.- Returns:
- 1 if there is no header present; the decoded header value otherwise.
-
getHeader
Get a header value with a specific type.- Type Parameters:
T
- the type.- Parameters:
key
- the header name.type
- the type'sClass
.- Returns:
- the value, if present.
- Throws:
IllegalArgumentException
- if the type is not correct.
-
createAccessor
- Overrides:
createAccessor
in classMessageHeaderAccessor
-
wrap
Create an instance from the payload and headers of the given Message.- Parameters:
message
- the message.- Returns:
- the accessor.
-