3. Schritt Live-Umbau: Nicht mehr benötigte Properties aus `ApplicationProperties...
authorKai Moritz <kai@juplo.de>
Wed, 7 May 2025 18:16:15 +0000 (20:16 +0200)
committerKai Moritz <kai@juplo.de>
Wed, 7 May 2025 18:44:41 +0000 (20:44 +0200)
src/main/java/de/juplo/kafka/ApplicationConfiguration.java
src/main/java/de/juplo/kafka/ApplicationProperties.java

index 6088992..b117a09 100644 (file)
@@ -1,6 +1,7 @@
 package de.juplo.kafka;
 
 import org.apache.kafka.clients.producer.Producer;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.Bean;
@@ -16,13 +17,14 @@ public class ApplicationConfiguration
 {
   @Bean
   public ExampleProducer exampleProducer(
+    @Value("${spring.kafka.client-id}") String clientId,
     ApplicationProperties properties,
     Producer<String, String> kafkaProducer,
     ConfigurableApplicationContext applicationContext)
   {
     return
       new ExampleProducer(
-        properties.getClientId(),
+        clientId,
         properties.getProducerProperties().getTopic(),
         properties.getProducerProperties().getThrottle() == null
           ? Duration.ofMillis(500)
index 4323262..908072c 100644 (file)
@@ -16,13 +16,6 @@ import java.time.Duration;
 @Setter
 public class ApplicationProperties
 {
-  @NotNull
-  @NotEmpty
-  private String bootstrapServer;
-  @NotNull
-  @NotEmpty
-  private String clientId;
-
   @NotNull
   private ProducerProperties producer;
 
@@ -41,22 +34,6 @@ public class ApplicationProperties
     @NotNull
     @NotEmpty
     private String topic;
-    @NotNull
-    @NotEmpty
-    private String acks;
-    @NotNull
-    private Duration deliveryTimeout;
-    @NotNull
-    private Duration maxBlock;
-    @NotNull
-    private Long bufferMemory;
-    @NotNull
-    private Integer batchSize;
-    @NotNull
-    private Duration linger;
-    @NotNull
-    @NotEmpty
-    private String compressionType;
     private Duration throttle;
   }
 }