From 6bf8a76c6ea35849e063941bcaa744ce50a8f99a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 4 Nov 2022 11:05:15 +0100 Subject: [PATCH] WIP:TaskExecutor-NEU --- src/main/java/de/juplo/kafka/Application.java | 6 +++--- src/main/java/de/juplo/kafka/ApplicationConfiguration.java | 3 --- src/main/java/de/juplo/kafka/ApplicationProperties.java | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index 705f52f..3828b1d 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -7,10 +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.scheduling.concurrent.ThreadPoolTaskExecutor; import javax.annotation.PreDestroy; import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -19,7 +19,7 @@ import java.util.concurrent.Future; public class Application implements ApplicationRunner { @Autowired - ExecutorService executorService; + ThreadPoolTaskExecutor taskExecutor; @Autowired Consumer kafkaConsumer; @Autowired @@ -31,7 +31,7 @@ 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 diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 16926fd..de77c60 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -8,9 +8,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.kafka.core.ConsumerFactory; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - @Configuration @EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class }) diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index d46a8b3..a4cc8b8 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -7,7 +7,6 @@ import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; -import java.time.Duration; @ConfigurationProperties(prefix = "simple.consumer") @@ -19,5 +18,4 @@ public class ApplicationProperties @NotNull @NotEmpty private String topic; - private Duration throttle; } -- 2.20.1