Protobuf
Requirements
Application-side setup
var properties = new Properties();
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaProtobufSerializer.class);
properties.setProperty("bootstrap.servers", "localhost:9092");
properties.setProperty("schema.registry.url", "http://localhost:8081");
KafkaProducer<String, CardData.CreditCard> producer = new KafkaProducer<>(properties);
var topic = "protobuf-topic";
customers.forEach(customer -> {
var cardData = CardData.CreditCard.newBuilder()
.setName(customer.name)
.setCountry(customer.countryCode)
.setCurrency(customer.card.currency)
.setBlocked(customer.card.isBlocked)
.setType(customer.card.cardType)
.setCardNumber(customer.card.number)
.build();
var record = new ProducerRecord<String, CardData.CreditCard>(topic, customer.id, cardData);
producer.send(record);
});
producer.close();Build and deploy
Interacting with your data
Current limitations
Last updated
Was this helpful?

