b2f08171948c73704e8d6093b0ede8d85c35087d
[demos/kafka/training] / src / main / java / de / juplo / kafka / Application.java
1 package de.juplo.kafka;
2
3 import org.springframework.boot.SpringApplication;
4 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
6 import org.springframework.boot.context.properties.EnableConfigurationProperties;
7 import org.springframework.context.annotation.Bean;
8 import org.springframework.kafka.annotation.EnableKafka;
9 import org.springframework.kafka.core.KafkaTemplate;
10
11
12 @SpringBootApplication
13 @EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class })
14 @EnableKafka
15 public class Application
16 {
17   @Bean
18   public RestGateway restGateway(
19       ApplicationProperties applicationProperties,
20       KafkaProperties kafkaProperties,
21       KafkaTemplate<String, Integer> kafkaTemplate)
22   {
23     return
24         new RestGateway(
25             kafkaProperties.getClientId(),
26             applicationProperties.getTopic(),
27             applicationProperties.getPartition(),
28             kafkaTemplate);
29   }
30
31
32   public static void main(String[] args)
33   {
34     SpringApplication.run(Application.class, args);
35   }
36 }