T
- class of the entity, representing messagespublic class JsonSerializer<T>
extends java.lang.Object
implements org.apache.kafka.common.serialization.Serializer<T>
Serializer
for sending Java objects to Kafka as JSON.Modifier and Type | Field and Description |
---|---|
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
Constructor and Description |
---|
JsonSerializer() |
JsonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
configure(java.util.Map<java.lang.String,?> configs,
boolean isKey) |
byte[] |
serialize(java.lang.String topic,
T data) |
public JsonSerializer()
public JsonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public void configure(java.util.Map<java.lang.String,?> configs, boolean isKey)
configure
in interface org.apache.kafka.common.serialization.Serializer<T>
public byte[] serialize(java.lang.String topic, T data)
serialize
in interface org.apache.kafka.common.serialization.Serializer<T>
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface org.apache.kafka.common.serialization.Serializer<T>