From: Kai Moritz Date: Sat, 9 Apr 2022 11:21:43 +0000 (+0200) Subject: Refaktorisierung für Tests - ExecutorService als separate Bean erzeugt X-Git-Tag: deserialization-synchroner-test~10 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=31dc17e7f5ac937f21882ec28b3234c5c398e840;p=demos%2Fkafka%2Ftraining Refaktorisierung für Tests - ExecutorService als separate Bean erzeugt --- diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 58f44fa..76d0c8a 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.Properties; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -18,16 +19,23 @@ public class ApplicationConfiguration @Bean public EndlessConsumer endlessConsumer( KafkaConsumer kafkaConsumer, + ExecutorService executor, ApplicationProperties properties) { return new EndlessConsumer( - Executors.newFixedThreadPool(1), + executor, properties.getClientId(), properties.getTopic(), kafkaConsumer); } + @Bean + public ExecutorService executor() + { + return Executors.newSingleThreadExecutor(); + } + @Bean(destroyMethod = "close") public KafkaConsumer kafkaConsumer(ApplicationProperties properties) {