From e37dafaa5ce8333033dff1b0479d7b580e5f1a4e Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 4 Nov 2022 09:48:08 +0100 Subject: [PATCH] WIP:async --- src/main/java/de/juplo/kafka/Application.java | 7 ------- src/main/java/de/juplo/kafka/SimpleConsumer.java | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index 513a293..d4c0885 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -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(); diff --git a/src/main/java/de/juplo/kafka/SimpleConsumer.java b/src/main/java/de/juplo/kafka/SimpleConsumer.java index 5305ceb..dac22a2 100644 --- a/src/main/java/de/juplo/kafka/SimpleConsumer.java +++ b/src/main/java/de/juplo/kafka/SimpleConsumer.java @@ -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 -- 2.20.1