io.github.clescot.kafka.connect.http.HttpExchangeSerdeFactory Maven / Gradle / Ivy
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;
}
}