vigneshwar reddy
vigneshwar reddy

Reputation: 185

How to store data on topic which will be passed as a message through producer, such that it can loaded to database on respective columns

I followed this blog to produce a message on to topic using kafka spring so far.

The message I'm going to pass is just the name and now I would like to stream through this topic and add incremental value as ID along with name and store it on OutputTopic and now, I would like to store data to cassandra.

My table structure in cassandra as follows:-

CREATE TABLE emp(
   emp_id int PRIMARY KEY,
   emp_name text,
   )

In which format the data should be on output topic so that I can easily store it on cassandra table?

How can I achieve the above functionality?

Upvotes: 1

Views: 670

Answers (1)

Erick Ramirez
Erick Ramirez

Reputation: 16343

Once you've got the data published on a Kafka topic, you can just use the DataStax Kafka connector for Apache Cassandra, DataStax Enterprise and Astra DB.

The connector lets you save records from a Kafka topic to Cassandra tables. It is open-source so it's free to use.

There's a working example here that includes a Cassandra table schema, details of how to configure the Kafka sink connector and map a topic to the CQL table. Cheers!

Upvotes: 1

Related Questions