Class KafkaMessageHeaderAccessor
java.lang.Object
org.springframework.messaging.support.MessageHeaderAccessor
org.springframework.kafka.support.KafkaMessageHeaderAccessor
public class KafkaMessageHeaderAccessor
extends org.springframework.messaging.support.MessageHeaderAccessor
A header accessor to provide convenient access to certain headers in a
type specific manner.
- Since:
- 3.0.10
-
Field Summary
Fields inherited from class org.springframework.messaging.support.MessageHeaderAccessor
DEFAULT_CHARSET
-
Constructor Summary
ConstructorsConstructorDescriptionKafkaMessageHeaderAccessor
(org.springframework.messaging.Message<?> message) Construct an instance for the provided message. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.messaging.support.MessageHeaderAccessor
createAccessor
(org.springframework.messaging.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
wrap
(org.springframework.messaging.Message<?> message) 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
public KafkaMessageHeaderAccessor(org.springframework.messaging.Message<?> message) 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:
- 1 if there is no header present; the decoded header value otherwise.
- 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
protected org.springframework.messaging.support.MessageHeaderAccessor createAccessor(org.springframework.messaging.Message<?> message) - Overrides:
createAccessor
in classorg.springframework.messaging.support.MessageHeaderAccessor
-
wrap
Create an instance from the payload and headers of the given Message.- Parameters:
message
- the message.- Returns:
- the accessor.
-