public class KafkaLargeMessageSerdeProcessor {
public void processLargeMessageSerde(String filename, String topicName) throws IOException {
final Properties props = new Properties();
props.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
props.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, "s3-backed-serde-app");
props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class);
props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, S3BackedSerde.class);
props.setProperty(AbstractS3BackedConfig.BASE_PATH_CONFIG, "s3://large-blob-data-test/");
props.put(S3BackedSerdeConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.StringSerde.class);
Producer<String, String> producer = new KafkaProducer<>(props);
FileInputStream inputStream;
try {
inputStream = new FileInputStream(filename);
byte[] buffer = new byte[1024 * 1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
String chunk = new String(buffer, 0, bytesRead, StandardCharsets.UTF_8);
ProducerRecord<String, String> record = new ProducerRecord<>(topicName, chunk);
producer.send(record);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
producer.close();
inputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Exception in thread "main" org.apache.kafka.common.config.ConfigException: Invalid value null for configuration key.serializer: must be non-null.
at org.apache.kafka.clients.producer.ProducerConfig.appendSerializerToConfig(ProducerConfig.java:579)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:290)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:317)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:302)
at com.example.KafkaLargeMessageSerdeProcessor.processLargeMessageSerde(KafkaLargeMessageSerdeProcessor.java:29)
at com.example.Main.main(Main.java:14)
I just want to know what I'm missing here.