From e09650509adafd0b28f141ea1302fa27ba69b73a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 5 Sep 2022 18:32:03 +0200 Subject: [PATCH] WIP --- src/main/java/de/juplo/kafka/ApplicationConfiguration.java | 1 + src/main/java/de/juplo/kafka/ApplicationProperties.java | 6 ++++++ src/main/java/de/juplo/kafka/RestGateway.java | 3 ++- src/test/java/de/juplo/kafka/ApplicationTests.java | 3 +-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index d040f90..59652c0 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -22,6 +22,7 @@ public class ApplicationConfiguration return new RestGateway( kafkaProperties.getClientId(), + applicationProperties.getTopic(), applicationProperties.getPartition(), kafkaTemplate); } diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index d0e694d..7d5f105 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -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; } diff --git a/src/main/java/de/juplo/kafka/RestGateway.java b/src/main/java/de/juplo/kafka/RestGateway.java index 2f2b18c..96b9cd8 100644 --- a/src/main/java/de/juplo/kafka/RestGateway.java +++ b/src/main/java/de/juplo/kafka/RestGateway.java @@ -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 kafkaTemplate; @@ -35,7 +36,7 @@ public class RestGateway final long time = System.currentTimeMillis(); ListenableFuture> future = - kafkaTemplate.send(null, partition, key, value); + kafkaTemplate.send(topic, partition, key, value); long now = System.currentTimeMillis(); diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index b7d3e7f..8de4b8a 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -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) -- 2.20.1