1 package de.juplo.kafka;
3 import lombok.extern.slf4j.Slf4j;
4 import org.apache.kafka.clients.consumer.Consumer;
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.boot.ApplicationArguments;
7 import org.springframework.boot.ApplicationRunner;
8 import org.springframework.boot.SpringApplication;
9 import org.springframework.boot.autoconfigure.SpringBootApplication;
11 import javax.annotation.PreDestroy;
12 import java.util.concurrent.ExecutionException;
13 import java.util.concurrent.Executor;
14 import java.util.concurrent.Future;
17 @SpringBootApplication
19 public class Application implements ApplicationRunner
24 Consumer<?, ?> kafkaConsumer;
26 SimpleConsumer simpleConsumer;
29 public void run(ApplicationArguments args) throws Exception
31 log.info("Starting SimpleConsumer");
32 executor.execute(simpleConsumer);
36 public void shutdown() throws ExecutionException, InterruptedException
38 log.info("Signaling SimpleConsumer to quit its work");
39 kafkaConsumer.wakeup();
43 public static void main(String[] args)
45 SpringApplication.run(Application.class, args);