WIP:TaskExecutor-NEU
[demos/kafka/training] / src / main / java / de / juplo / kafka / Application.java
index 862c5f2..3828b1d 100644 (file)
@@ -7,12 +7,10 @@ import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.kafka.core.ConsumerFactory;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import javax.annotation.PreDestroy;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
 
@@ -21,9 +19,9 @@ import java.util.concurrent.Future;
 public class Application implements ApplicationRunner
 {
   @Autowired
-  ExecutorService executorService;
+  ThreadPoolTaskExecutor taskExecutor;
   @Autowired
-  Consumer<String, Message> consumer;
+  Consumer<?, ?> kafkaConsumer;
   @Autowired
   SimpleConsumer simpleConsumer;
 
@@ -33,14 +31,14 @@ public class Application implements ApplicationRunner
   public void run(ApplicationArguments args) throws Exception
   {
     log.info("Starting SimpleConsumer");
-    consumerJob = executorService.submit(simpleConsumer);
+    consumerJob = taskExecutor.submit(simpleConsumer);
   }
 
   @PreDestroy
   public void shutdown() throws ExecutionException, InterruptedException
   {
     log.info("Signaling SimpleConsumer to quit its work");
-    consumer.wakeup();
+    kafkaConsumer.wakeup();
     log.info("Waiting for SimpleConsumer to finish its work");
     consumerJob.get();
     log.info("SimpleConsumer finished its work");