Class DefaultKafkaHeaderMapper
java.lang.Object
org.springframework.kafka.support.AbstractKafkaHeaderMapper
org.springframework.kafka.support.DefaultKafkaHeaderMapper
- All Implemented Interfaces:
- KafkaHeaderMapper
@Deprecated(forRemoval=true,
            since="4.0")
public class DefaultKafkaHeaderMapper
extends AbstractKafkaHeaderMapper
Deprecated, for removal: This API element is subject to removal in a future version.
Default header mapper for Apache Kafka.
 Most headers in 
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.- Since:
- 1.3
- Author:
- Gary Russell, Artem Bilan, Soby Chacko, Sanghyoek An
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classDeprecated, for removal: This API element is subject to removal in a future version.Represents a header that could not be decoded due to an untrusted type.Nested classes/interfaces inherited from class org.springframework.kafka.support.AbstractKafkaHeaderMapperAbstractKafkaHeaderMapper.HeaderMatcher, AbstractKafkaHeaderMapper.NeverMatchHeaderMatcher, AbstractKafkaHeaderMapper.SimplePatternBasedHeaderMatcher
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.Header name for java types of other headers.Fields inherited from class org.springframework.kafka.support.AbstractKafkaHeaderMapperlogger
- 
Constructor SummaryConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.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) Deprecated, for removal: This API element is subject to removal in a future version.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, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Construct an instance with the provided object mapper and the provided header patterns for outbound headers; all inbound headers are mapped.DefaultKafkaHeaderMapper(String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Construct an instance with a default object mapper and the provided header patterns for outbound headers; all inbound headers are mapped.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddToStringClasses(String... classNames) Deprecated, for removal: This API element is subject to removal in a future version.Add class names that the outbound mapper should perform toString() operations on before mapping.voidaddTrustedPackages(String... packagesToTrust) Deprecated, for removal: This API element is subject to removal in a future version.Add packages to the trusted packages list used when constructing objects from JSON.static DefaultKafkaHeaderMapperforInboundOnlyWithMatchers(com.fasterxml.jackson.databind.ObjectMapper objectMapper, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Create an instance for inbound mapping only with pattern matching.static DefaultKafkaHeaderMapperforInboundOnlyWithMatchers(String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Create an instance for inbound mapping only with pattern matching.voidfromHeaders(MessageHeaders headers, org.apache.kafka.common.header.Headers target) Deprecated, for removal: This API element is subject to removal in a future version.Map from the givenMessageHeadersto the specified target headers.protected com.fasterxml.jackson.databind.ObjectMapperDeprecated, for removal: This API element is subject to removal in a future version.Return the object mapper.Deprecated, for removal: This API element is subject to removal in a future version.Provide direct access to the toString() classes by subclasses.Deprecated, for removal: This API element is subject to removal in a future version.Provide direct access to the trusted packages set for subclasses.protected booleanDeprecated, for removal: This API element is subject to removal in a future version.voidsetEncodeStrings(boolean encodeStrings) Deprecated, for removal: This API element is subject to removal in a future version.Set to true to encode String-valued headers as JSON string ("..."), by default just the raw String value is converted to a byte array using the configured charset.voidDeprecated, for removal: This API element is subject to removal in a future version.Map from the given native headers to a map of headers for the eventualMessageHeaders.protected booleanDeprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class org.springframework.kafka.support.AbstractKafkaHeaderMapperaddMatchers, addRawMappedHeader, doesMatchMultiValueHeader, fromUserHeader, getCharset, headerValueToAddIn, headerValueToAddOut, matches, matches, matchesForInbound, setCharset, setMapAllStringsOut, setMultiValueHeaderPatterns, setRawMappedHeaders
- 
Field Details- 
JSON_TYPESDeprecated, for removal: This API element is subject to removal in a future version.Header name for java types of other headers.- See Also:
 
 
- 
- 
Constructor Details- 
DefaultKafkaHeaderMapperpublic DefaultKafkaHeaderMapper()Deprecated, for removal: This API element is subject to removal in a future version.Construct an instance with the default object mapper and default header patterns for outbound headers; all inbound headers are mapped. The default pattern list is"!id", "!timestamp" and "*". In addition, most of the headers inKafkaHeadersare never mapped as headers since they represent data in consumer/producer records.- See Also:
 
- 
DefaultKafkaHeaderMapperpublic DefaultKafkaHeaderMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Construct an instance with the provided object mapper and default header patterns for outbound headers; all inbound headers are mapped. The patterns are applied in order, stopping on the first match (positive or negative). Patterns are negated by preceding them with "!". The default pattern list is"!id", "!timestamp" and "*". In addition, most of the headers inKafkaHeadersare never mapped as headers since they represent data in consumer/producer records.- Parameters:
- objectMapper- the object mapper.
- See Also:
 
- 
DefaultKafkaHeaderMapperDeprecated, for removal: This API element is subject to removal in a future version.Construct an instance with a default object mapper and the provided header patterns for outbound headers; all inbound headers are mapped. The patterns are applied in order, stopping on the first match (positive or negative). Patterns are negated by preceding them with "!". The patterns will replace the default patterns; you generally should not map the"id" and "timestamp"headers. Note: most of the headers inKafkaHeadersare ever mapped as headers since they represent data in consumer/producer records.- Parameters:
- patterns- the patterns.
- See Also:
 
- 
DefaultKafkaHeaderMapperpublic DefaultKafkaHeaderMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Construct an instance with the provided object mapper and the provided header patterns for outbound headers; all inbound headers are mapped. The patterns are applied in order, stopping on the first match (positive or negative). Patterns are negated by preceding them with "!". The patterns will replace the default patterns; you generally should not map the"id" and "timestamp"headers. Note: most of the headers inKafkaHeadersare never mapped as headers since they represent data in consumer/producer records.- Parameters:
- objectMapper- the object mapper.
- patterns- the patterns.
- See Also:
 
 
- 
- 
Method Details- 
forInboundOnlyWithMatchersDeprecated, for removal: This API element is subject to removal in a future version.Create an instance for inbound mapping only with pattern matching.- Parameters:
- patterns- the patterns to match.
- Returns:
- the header mapper.
- Since:
- 2.8.8
 
- 
forInboundOnlyWithMatcherspublic static DefaultKafkaHeaderMapper forInboundOnlyWithMatchers(com.fasterxml.jackson.databind.ObjectMapper objectMapper, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Create an instance for inbound mapping only with pattern matching.- Parameters:
- objectMapper- the object mapper.
- patterns- the patterns to match.
- Returns:
- the header mapper.
- Since:
- 2.8.8
 
- 
getObjectMapperprotected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Deprecated, for removal: This API element is subject to removal in a future version.Return the object mapper.- Returns:
- the mapper.
 
- 
getTrustedPackages
- 
getToStringClasses
- 
isEncodeStringsprotected boolean isEncodeStrings()Deprecated, for removal: This API element is subject to removal in a future version.
- 
setEncodeStringspublic void setEncodeStrings(boolean encodeStrings) Deprecated, for removal: This API element is subject to removal in a future version.Set to true to encode String-valued headers as JSON string ("..."), by default just the raw String value is converted to a byte array using the configured charset. Set to true if a consumer of the outbound record is using Spring for Apache Kafka version less than 2.3- Parameters:
- encodeStrings- true to encode (default false).
- Since:
- 2.3
 
- 
addTrustedPackagesDeprecated, for removal: This API element is subject to removal in a future version.Add packages to the trusted packages list used when constructing objects from JSON. By default, the following packages are trusted:- java.lang
- java.net
- java.util
- org.springframework.util
 "*", all packages are trusted. If a class for a non-trusted package is encountered, the header is returned to the application with value of typeDefaultKafkaHeaderMapper.NonTrustedHeaderType.- Parameters:
- packagesToTrust- the packages to trust.
 
- 
addToStringClassesDeprecated, for removal: This API element is subject to removal in a future version.Add class names that the outbound mapper should perform toString() operations on before mapping.- Parameters:
- classNames- the class names.
- Since:
- 2.2
 
- 
fromHeadersDeprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:KafkaHeaderMapperMap from the givenMessageHeadersto the specified target headers.- Parameters:
- headers- the abstracted MessageHeaders.
- target- the native target headers.
 
- 
toHeadersDeprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:KafkaHeaderMapperMap from the given native headers to a map of headers for the eventualMessageHeaders.- Parameters:
- source- the native headers.
- headers- the target headers.
 
- 
trustedDeprecated, for removal: This API element is subject to removal in a future version.
 
- 
JsonKafkaHeaderMapperfor Jackson 3.