1 package de.juplo.kafka;
3 import org.apache.kafka.clients.consumer.Consumer;
4 import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
5 import org.springframework.boot.context.properties.EnableConfigurationProperties;
6 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration;
9 import org.springframework.kafka.core.ConsumerFactory;
13 @EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class })
14 public class ApplicationConfiguration
17 public AdderBusinessLogic adder()
19 return new AdderBusinessLogic();
23 public MessageHandler messageHandler(
24 KafkaProperties properties,
25 AdderBusinessLogic adder)
27 return new MessageHandler(
28 properties.getClientId(),
33 public SimpleConsumer simpleConsumer(
34 Consumer<String, Message> kafkaConsumer,
35 MessageHandler messageHandler,
36 KafkaProperties kafkaProperties,
37 ApplicationProperties applicationProperties)
41 kafkaProperties.getClientId(),
42 applicationProperties.getTopic(),
48 public Consumer<?, ?> kafkaConsumer(ConsumerFactory<?, ?> factory)
50 return factory.createConsumer();