WIP:TaskExecutor-NEU
[demos/kafka/training] / src / main / java / de / juplo / kafka / Application.java
index d4c0885..a9b466d 100644 (file)
@@ -7,19 +7,21 @@ import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.scheduling.annotation.EnableAsync;
 
 import javax.annotation.PreDestroy;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
 
 
 @SpringBootApplication
-@EnableAsync
 @Slf4j
 public class Application implements ApplicationRunner
 {
   @Autowired
-  Consumer<?, ?> consumer;
+  Executor executor;
+  @Autowired
+  Consumer<?, ?> kafkaConsumer;
   @Autowired
   SimpleConsumer simpleConsumer;
 
@@ -27,14 +29,14 @@ public class Application implements ApplicationRunner
   public void run(ApplicationArguments args) throws Exception
   {
     log.info("Starting SimpleConsumer");
-    simpleConsumer.run();
+    executor.execute(simpleConsumer);
   }
 
   @PreDestroy
-  public void stop() throws ExecutionException, InterruptedException
+  public void shutdown() throws ExecutionException, InterruptedException
   {
     log.info("Signaling SimpleConsumer to quit its work");
-    consumer.wakeup();
+    kafkaConsumer.wakeup();
   }