https://grokonez.com/java-integration/distributed-system/how-to-start-spring-kafka-application-with-spring-boot

How to start Spring Kafka Application with Spring Boot

The Spring Apache Kafka (spring-kafka) provides a high-level abstraction for Kafka-based messaging solutions. And in the previous post, We had developed a Spring Kafka Application with the auto-configuration supported by SpringBoot (from version 1.5). But when we need explicitly configure Kafka factories (Kafka Producer and Kafka Consumer) for development, how to do it? So in the tutorial, JavaSampleApproach will introduce an alternative solution by manually configure Kafka factories to build a Spring Kafka Application.

Related Articles:

I. Technologies

– Java 8 – Maven build – Spring Boot – Spring Kafka – Apache Kafka – Spring Tool Suite editor

II. Overview

Spring Kafka Application - architecture

We will explicitly implement a ProducerFactory and ConsumerFactory with customized properties:


@Bean

public ProducerFactory producerFactory() {
    Map configProps = new HashMap<>();
    ...
    return new DefaultKafkaProducerFactory<>(configProps);
}

@Bean
public ConsumerFactory consumerFactory() {
    Map props = new HashMap<>();
    ...
    return new DefaultKafkaConsumerFactory<>(props);
}

Then use ProducerFactory to build KafkaTemplate and use ConsumerFactory to build
ConcurrentKafkaListenerContainerFactory which will handle @KafkaListener later:

More at:

https://grokonez.com/java-integration/distributed-system/how-to-start-spring-kafka-application-with-spring-boot

How to start Spring Kafka Application with Spring Boot

#springboot #activemq #spring-kafka #kafka

How to start Spring Kafka Application with Spring Boot » grokonez
1.55 GEEK