1 package de.juplo.kafka;
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 import org.springframework.util.Assert;
10 import java.util.concurrent.Executors;
13 @SpringBootApplication
14 @EnableConfigurationProperties(ApplicationProperties.class)
15 public class Application
18 ApplicationProperties properties;
22 public EndlessProducer producer()
24 Assert.hasText(properties.getBootstrapServer(), "producer.bootstrap-server must be set");
25 Assert.hasText(properties.getClientId(), "producer.client-id must be set");
26 Assert.hasText(properties.getTopic(), "producer.topic must be set");
28 EndlessProducer producer =
30 Executors.newFixedThreadPool(1),
31 properties.getBootstrapServer(),
32 properties.getClientId(),
33 properties.getTopic(),
35 properties.getThrottleMs());
42 public static void main(String[] args)
44 SpringApplication.run(Application.class, args);