Merge der überarbeiteten Compose-Konfiguration ('rebalance-listener')
[demos/kafka/training] / src / main / java / de / juplo / kafka / Application.java
1 package de.juplo.kafka;
2
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.boot.SpringApplication;
5 import org.springframework.boot.autoconfigure.SpringBootApplication;
6 import org.springframework.boot.context.properties.EnableConfigurationProperties;
7 import org.springframework.context.annotation.Bean;
8
9 import java.util.concurrent.Executors;
10
11
12 @SpringBootApplication
13 @EnableConfigurationProperties(ApplicationProperties.class)
14 public class Application
15 {
16   @Autowired
17   ApplicationProperties properties;
18
19
20   @Bean
21   public EndlessConsumer consumer(PartitionStatisticsRepository repository)
22   {
23     EndlessConsumer consumer =
24         new EndlessConsumer(
25             Executors.newFixedThreadPool(1),
26             repository,
27             properties.getBootstrapServer(),
28             properties.getGroupId(),
29             properties.getClientId(),
30             properties.getTopic(),
31             properties.getAutoOffsetReset());
32
33     consumer.start();
34
35     return consumer;
36   }
37
38   public static void main(String[] args)
39   {
40     SpringApplication.run(Application.class, args);
41   }
42 }