io.quarkus.kafka.client.serialization.ObjectMapperSerde Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kafka-client Show documentation
Show all versions of quarkus-kafka-client Show documentation
Connect to Apache Kafka with its native API
package io.quarkus.kafka.client.serialization;
import java.util.Map;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serde;
import org.apache.kafka.common.serialization.Serializer;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* A {@link Serde} that (de-)serializes JSON using Jackson's ObjectMapper.
*/
public class ObjectMapperSerde implements Serde {
private final ObjectMapperSerializer serializer;
private final ObjectMapperDeserializer deserializer;
public ObjectMapperSerde(Class type) {
this(type, ObjectMapperProducer.get());
}
public ObjectMapperSerde(Class type, ObjectMapper objectMapper) {
this.serializer = new ObjectMapperSerializer(objectMapper);
this.deserializer = new ObjectMapperDeserializer(type, objectMapper);
}
@Override
public void configure(Map configs, boolean isKey) {
}
@Override
public void close() {
serializer.close();
deserializer.close();
}
@Override
public Serializer serializer() {
return serializer;
}
@Override
public Deserializer deserializer() {
return deserializer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy