BdEngineer
BdEngineer

Reputation: 3179

How to send List of Objects to kafka topic using spring-kafka framework?

Me using spring-kafka in spring-boot application to send the data topic. I need to fetch the data from a oracle table and send it.

I fetch List from oracle table. How to send them to topic ?

i.e.

  1. Is there any way to send them as a List ? if yes how ? If yes, then how to deserialize it at consumer side ?

  2. Is it possible to send data like a streaming fashion using spring-book and spring-kafka ? if yes any more info or sample/snippet plz ...

How to handle partitionKey if I send List at a time?

Currently I am sending individual Company obj hence have key defined as below

companyKafkaTemplate.send(COMPANY_TOPIC,this.getKey(company), company);

Upvotes: 3

Views: 9762

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

For a List serialization and deserialization I would suggest to use a JSON support in Spring Kafka: https://docs.spring.io/spring-kafka/docs/2.2.7.RELEASE/reference/html/#serdes

For a streaming I would suggest to take a look into a Reactive support in Spring Kafka, based on the Reactor Kafka project: https://github.com/reactor/reactor-kafka

For that purpose we provide a ReactiveKafkaProducerTemplate and ReactiveKafkaConsumerTemplate.

Upvotes: 1

Related Questions