WIP:async
authorKai Moritz <kai@juplo.de>
Fri, 4 Nov 2022 08:48:08 +0000 (09:48 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 4 Nov 2022 11:52:13 +0000 (12:52 +0100)
src/main/java/de/juplo/kafka/Application.java
src/main/java/de/juplo/kafka/SimpleConsumer.java

index 513a293..d4c0885 100644 (file)
@@ -7,7 +7,6 @@ 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.Async;
 import org.springframework.scheduling.annotation.EnableAsync;
 
 import javax.annotation.PreDestroy;
@@ -26,12 +25,6 @@ public class Application implements ApplicationRunner
 
   @Override
   public void run(ApplicationArguments args) throws Exception
-  {
-    start();
-  }
-
-  @Async
-  public void start()
   {
     log.info("Starting SimpleConsumer");
     simpleConsumer.run();
index 5305ceb..dac22a2 100644 (file)
@@ -6,6 +6,7 @@ import org.apache.kafka.clients.consumer.Consumer;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.apache.kafka.clients.consumer.ConsumerRecords;
 import org.apache.kafka.common.errors.WakeupException;
+import org.springframework.scheduling.annotation.Async;
 
 import java.time.Duration;
 import java.util.Arrays;
@@ -22,6 +23,7 @@ public class SimpleConsumer
   private long consumed = 0;
 
 
+  @Async
   public void run()
   {
     try