All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.kafka.client.serialization.ObjectMapperSerde Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
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