by Visit https://start.spring.io and add the following dependencies: This demo makes use of Gradle as the build option.

Add the following lines of code: We can send the message to the topic in two ways, which are listed below.

The next method of sending a message to Kafka topic is to use the KafkaProducer object.

This method is used to listen for the message with the help of the @KafkaListener annotation and prints the message on the console once it is available in the topic.

Related Articles