public class DefaultKafkaHeaderMapper extends AbstractKafkaHeaderMapper
KafkaHeaders are not mapped on outbound messages.
The exceptions are correlation and reply headers for request/reply
messaging.
Header types are added to a special header JSON_TYPES.| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultKafkaHeaderMapper.NonTrustedHeaderType
Represents a header that could not be decoded due to an untrusted type.
|
AbstractKafkaHeaderMapper.SimplePatternBasedHeaderMatcher| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JSON_TYPES
Header name for java types of other headers.
|
logger, matchers| Constructor and Description |
|---|
DefaultKafkaHeaderMapper()
Construct an instance with the default object mapper and default header patterns
for outbound headers; all inbound headers are mapped.
|
DefaultKafkaHeaderMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Construct an instance with the provided object mapper and default header patterns
for outbound headers; all inbound headers are mapped.
|
DefaultKafkaHeaderMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
java.lang.String... patterns)
Construct an instance with the provided object mapper and the provided header
patterns for outbound headers; all inbound headers are mapped.
|
DefaultKafkaHeaderMapper(java.lang.String... patterns)
Construct an instance with a default object mapper and the provided header patterns
for outbound headers; all inbound headers are mapped.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToStringClasses(java.lang.String... classNames)
Add class names that the outbound mapper should perform toString() operations on
before mapping.
|
void |
addTrustedPackages(java.lang.String... packagesToTrust)
Add packages to the trusted packages list (default
java.util, java.lang) used
when constructing objects from JSON. |
void |
fromHeaders(org.springframework.messaging.MessageHeaders headers,
org.apache.kafka.common.header.Headers target)
Map from the given
MessageHeaders to the specified target message. |
protected com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Return the object mapper.
|
protected java.util.Set<java.lang.String> |
getToStringClasses()
Provide direct access to the toString() classes by subclasses.
|
protected java.util.Set<java.lang.String> |
getTrustedPackages()
Provide direct access to the trusted packages set for subclasses.
|
void |
toHeaders(org.apache.kafka.common.header.Headers source,
java.util.Map<java.lang.String,java.lang.Object> headers)
Map from the given target message to abstracted
MessageHeaders. |
protected boolean |
trusted(java.lang.String requestedType) |
getCharset, headertValueToAddIn, headerValueToAddOut, matches, matches, setCharset, setMapAllStringsOut, setRawMappedHaeaderspublic static final java.lang.String JSON_TYPES
public DefaultKafkaHeaderMapper()
"!id", "!timestamp" and "*". In addition, most of the headers in
KafkaHeaders are never mapped as headers since they represent data in
consumer/producer records.DefaultKafkaHeaderMapper(ObjectMapper)public DefaultKafkaHeaderMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
"!id", "!timestamp" and "*". In addition, most of the headers in
KafkaHeaders are never mapped as headers since they represent data in
consumer/producer records.objectMapper - the object mapper.PatternMatchUtils.simpleMatch(String, String)public DefaultKafkaHeaderMapper(java.lang.String... patterns)
"id" and "timestamp" headers. Note:
most of the headers in KafkaHeaders are ever mapped as headers since they
represent data in consumer/producer records.patterns - the patterns.PatternMatchUtils.simpleMatch(String, String)public DefaultKafkaHeaderMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
java.lang.String... patterns)
"id" and "timestamp" headers. Note: most
of the headers in KafkaHeaders are never mapped as headers since they
represent data in consumer/producer records.objectMapper - the object mapper.patterns - the patterns.PatternMatchUtils.simpleMatch(String, String)protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
protected java.util.Set<java.lang.String> getTrustedPackages()
protected java.util.Set<java.lang.String> getToStringClasses()
public void addTrustedPackages(java.lang.String... packagesToTrust)
java.util, java.lang) used
when constructing objects from JSON.
If any of the supplied packages is "*", all packages are trusted.
If a class for a non-trusted package is encountered, the header is returned to the
application with value of type DefaultKafkaHeaderMapper.NonTrustedHeaderType.packagesToTrust - the packages to trust.public void addToStringClasses(java.lang.String... classNames)
classNames - the class names.public void fromHeaders(org.springframework.messaging.MessageHeaders headers,
org.apache.kafka.common.header.Headers target)
KafkaHeaderMapperMessageHeaders to the specified target message.headers - the abstracted MessageHeaders.target - the native target message.public void toHeaders(org.apache.kafka.common.header.Headers source,
java.util.Map<java.lang.String,java.lang.Object> headers)
KafkaHeaderMapperMessageHeaders.source - the native target message.headers - the target headers.protected boolean trusted(java.lang.String requestedType)