Spring Boot Kafka Microservices - #8 - Configure Kafka Producer in OrderService Microservice


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

Lecture - #8 - Configure Kafka Producer in OrderService Microservice

Configure Kafka Producer in an OrderService Microservice

Open the application.properties file of the order-service project and configure Kafka producer.
spring.kafka.producer.bootstrap-servers: localhost:9092
spring.kafka.producer.key-serializer: org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
spring.kafka.topic.name=order_topics
Let's understand the meaning of the above properties.

We are using the following Producer property to convert Java object into JSON:

spring.kafka.producer.value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
spring.kafka.producer.bootstrap-servers - Comma-delimited list of host: port pairs to use for establishing the initial connections to the Kafka cluster. Overrides the global property, for consumers.

spring.kafka.producer.key-serializer - Serializer class for keys.

spring.kafka.producer.value-serializer - Serializer class for values




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

Comments