Springify: `start()`/`stop()`/`destroy()` in EndlessConsumer wiederbelebt
[demos/kafka/training] / src / main / java / de / juplo / kafka / Application.java
index 6601e6d..f227bbe 100644 (file)
@@ -7,11 +7,6 @@ import org.springframework.boot.ApplicationRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
-import javax.annotation.PreDestroy;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-
 
 @SpringBootApplication
 @Slf4j
@@ -19,8 +14,6 @@ public class Application implements ApplicationRunner
 {
   @Autowired
   EndlessConsumer endlessConsumer;
-  @Autowired
-  ExecutorService executor;
 
 
   @Override
@@ -30,33 +23,6 @@ public class Application implements ApplicationRunner
     endlessConsumer.start();
   }
 
-  @PreDestroy
-  public void stopExecutor()
-  {
-    try
-    {
-      log.info("Shutting down the ExecutorService.");
-      executor.shutdown();
-      log.info("Waiting 5 seconds for the ExecutorService to terminate...");
-      executor.awaitTermination(5, TimeUnit.SECONDS);
-    }
-    catch (InterruptedException e)
-    {
-      log.error("Exception while waiting for the termination of the ExecutorService: {}", e.toString());
-    }
-    finally
-    {
-      if (!executor.isShutdown())
-      {
-        log.warn("Forcing shutdown of ExecutorService!");
-        executor
-            .shutdownNow()
-            .forEach(runnable -> log.warn("Unfinished task: {}", runnable.getClass().getSimpleName()));
-      }
-      log.info("Shutdow of ExecutorService finished");
-    }
-  }
-
 
   public static void main(String[] args)
   {