Spring Boot Kafka Microservices - #9 - Configure Kafka Topic in OrderService Microservice

Welcome to Spring Boot Kafka Event-Driven Microservices Series. In this lecture, we will Configure Kafka Topic in OrderService Microservice.

Lecture - #9 - Configure Kafka Topic in OrderService Microservice

Source Code - Configure Kafka Topic in OrderService Microservice

In an order-service project, create a config package. Within the config package, create a class named KafkaTopicConfig and add the following configuration to create the Kafka topic.

package net.javaguides.orderservice.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;

public class KafkaTopicConfig {

    private String topicName;

    // spring bean for kafka topic
    public NewTopic topic(){
        return TopicBuilder.name(topicName)

Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours

Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course