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

io.github.clescot.kafka.connect.http.HttpExchangeSerdeFactory Maven / Gradle / Ivy

There is a newer version: 0.7.232
Show newest version
package io.github.clescot.kafka.connect.http;

import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.streams.serdes.json.KafkaJsonSchemaSerde;
import io.github.clescot.kafka.connect.http.core.HttpExchange;
import org.apache.kafka.common.serialization.Serde;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class HttpExchangeSerdeFactory {

    private static final Logger LOGGER = LoggerFactory.getLogger(HttpExchangeSerdeFactory.class);
    private final SchemaRegistryClient schemaRegistryClient;
    private final Map serdeConfig;


    public HttpExchangeSerdeFactory(SchemaRegistryClient schemaRegistryClient,
                                    Map serdeConfig) {
        this.schemaRegistryClient = schemaRegistryClient;
        this.serdeConfig = serdeConfig;
    }

    public Serde buildValueSerde(){
        final KafkaJsonSchemaSerde jsonSchemaSerde = new KafkaJsonSchemaSerde<>(schemaRegistryClient,HttpExchange.class);
        serdeConfig.forEach((key, value) -> LOGGER.info("{}:{}", key, value));
        jsonSchemaSerde.configure(serdeConfig, false);
        return jsonSchemaSerde;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy