package de.juplo.kafka;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
-public class Application
+@Slf4j
+public class Application implements ApplicationRunner
{
+ @Autowired
+ EndlessConsumer endlessConsumer;
+
+
+ @Override
+ public void run(ApplicationArguments args) throws Exception
+ {
+ log.info("Starting EndlessConsumer");
+ endlessConsumer.start();
+ }
+
+
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
KafkaConsumer<String, String> kafkaConsumer,
ApplicationProperties properties)
{
- EndlessConsumer consumer =
+ return
new EndlessConsumer(
Executors.newFixedThreadPool(1),
properties.getClientId(),
properties.getTopic(),
kafkaConsumer);
-
- consumer.start();
-
- return consumer;
}
@Bean(destroyMethod = "close")