T
- class of the entity, representing messagespublic class JsonDeserializer<T>
extends java.lang.Object
implements org.apache.kafka.common.serialization.ExtendedDeserializer<T>
Deserializer
for receiving JSON from Kafka and return Java objects.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_KEY_TYPE
Kafka config property for the default key type if no header.
|
static java.lang.String |
DEFAULT_VALUE_TYPE
Kafka config property for the default value type if no header.
|
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
protected java.lang.Class<T> |
targetType |
static java.lang.String |
TRUSTED_PACKAGES
Kafka config property for trusted deserialization packages.
|
protected Jackson2JavaTypeMapper |
typeMapper |
Modifier | Constructor and Description |
---|---|
|
JsonDeserializer() |
|
JsonDeserializer(java.lang.Class<T> targetType) |
|
JsonDeserializer(java.lang.Class<T> targetType,
com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
protected |
JsonDeserializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
Modifier and Type | Method and Description |
---|---|
void |
addTrustedPackages(java.lang.String... packages)
Add trusted packages for deserialization.
|
void |
close() |
void |
configure(java.util.Map<java.lang.String,?> configs,
boolean isKey) |
T |
deserialize(java.lang.String topic,
byte[] data) |
T |
deserialize(java.lang.String topic,
org.apache.kafka.common.header.Headers headers,
byte[] data) |
Jackson2JavaTypeMapper |
getTypeMapper() |
void |
setTypeMapper(Jackson2JavaTypeMapper typeMapper)
Set a customized type mapper.
|
public static final java.lang.String DEFAULT_KEY_TYPE
public static final java.lang.String DEFAULT_VALUE_TYPE
public static final java.lang.String TRUSTED_PACKAGES
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected java.lang.Class<T> targetType
protected Jackson2JavaTypeMapper typeMapper
public JsonDeserializer()
protected JsonDeserializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public JsonDeserializer(java.lang.Class<T> targetType)
public JsonDeserializer(java.lang.Class<T> targetType, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public Jackson2JavaTypeMapper getTypeMapper()
public void setTypeMapper(Jackson2JavaTypeMapper typeMapper)
typeMapper
- the type mapper.public void configure(java.util.Map<java.lang.String,?> configs, boolean isKey)
configure
in interface org.apache.kafka.common.serialization.Deserializer<T>
public void addTrustedPackages(java.lang.String... packages)
packages
- the packages.public T deserialize(java.lang.String topic, org.apache.kafka.common.header.Headers headers, byte[] data)
deserialize
in interface org.apache.kafka.common.serialization.ExtendedDeserializer<T>
public T deserialize(java.lang.String topic, byte[] data)
deserialize
in interface org.apache.kafka.common.serialization.Deserializer<T>
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface org.apache.kafka.common.serialization.Deserializer<T>