Kafka messages using Protobuff in SpringBoot without schema Registry
I was trying to use the protobuff for the kafka event without using any schema registry. You. might be looking for the same and strugling how you can use protobuff protocol for your kafka messages to get a better throughput from Kafka.
before moving to the solution how to use protobuff you must have to understand what is protobuff and why you have to use it.
This is where you can go and understand about protobuff
To write a Kafka producer and consumer using the Protobuff
Here is the producer Config to produce protobuff event is
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("acks", "all");
props.put("retries", 0);
props.put("key.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer",
"org.apache.kafka.common.serialization.ByteArraySerializer");
KafkaProducer<String,byte[]> producer = new KafkaProducer<String, byte[]>(props);
Consumer configuration:
Properties properties = new Properties();
properties.put("bootstrap.servers", "localhost:9092");
properties.put("key-deserializer","org.apache.kafka.common.serialization.StringDeserializer");
properties.setProperty("value-deserializer","org.apache.kafka.common.serialization.ByteArrayDeserializer");
Please reach out to me if anyone have ay question.