WIP
authorKai Moritz <kai@juplo.de>
Mon, 5 Sep 2022 16:32:03 +0000 (18:32 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 5 Sep 2022 16:32:03 +0000 (18:32 +0200)
src/main/java/de/juplo/kafka/ApplicationConfiguration.java
src/main/java/de/juplo/kafka/ApplicationProperties.java
src/main/java/de/juplo/kafka/RestGateway.java
src/test/java/de/juplo/kafka/ApplicationTests.java

index d040f90..59652c0 100644 (file)
@@ -22,6 +22,7 @@ public class ApplicationConfiguration
     return
         new RestGateway(
             kafkaProperties.getClientId(),
+            applicationProperties.getTopic(),
             applicationProperties.getPartition(),
             kafkaTemplate);
   }
index d0e694d..7d5f105 100644 (file)
@@ -4,11 +4,17 @@ import lombok.Getter;
 import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
 
 @ConfigurationProperties(prefix = "sumup.gateway")
 @Getter
 @Setter
 public class ApplicationProperties
 {
+  @NotNull
+  @NotEmpty
+  private String topic;
   private Integer partition;
 }
index 2f2b18c..96b9cd8 100644 (file)
@@ -19,6 +19,7 @@ import org.springframework.web.context.request.async.DeferredResult;
 public class RestGateway
 {
   private final String id;
+  private final String topic;
   private final Integer partition;
   private final KafkaTemplate<String, Integer> kafkaTemplate;
 
@@ -35,7 +36,7 @@ public class RestGateway
     final long time = System.currentTimeMillis();
 
     ListenableFuture<SendResult<String, Integer>> future =
-        kafkaTemplate.send(null, partition, key, value);
+        kafkaTemplate.send(topic, partition, key, value);
 
     long now = System.currentTimeMillis();
 
index b7d3e7f..8de4b8a 100644 (file)
@@ -26,8 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 
 @SpringBootTest(
                properties = {
-                               "spring.kafka.consumer.bootstrap-servers=${spring.embedded.kafka.brokers}",
-                               "sumup.gateway.bootstrap-server=${spring.embedded.kafka.brokers}",
+                               "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
                                "sumup.gateway.topic=" + TOPIC})
 @AutoConfigureMockMvc
 @EmbeddedKafka(topics = TOPIC, partitions = PARTITIONS)