WIP:TaskExecutor-NEU
authorKai Moritz <kai@juplo.de>
Fri, 4 Nov 2022 10:05:15 +0000 (11:05 +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/ApplicationConfiguration.java
src/main/java/de/juplo/kafka/ApplicationProperties.java

index 705f52f..3828b1d 100644 (file)
@@ -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
index 16926fd..de77c60 100644 (file)
@@ -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 })
index d46a8b3..a4cc8b8 100644 (file)
@@ -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;
 }