From 6d6877ff078d4fa9d4709f8ff497488abded231b Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 17 Aug 2022 18:43:43 +0200 Subject: [PATCH] Parameter `partition` wiederbelebt * Wenn der Parameter gesetzt ist, schreibt das Gateway alle Nachrichten in die vorgegebene Partition. * Wenn der Parameter null ist, wird die Default-Partitionierung (Hashing by Key) verwendet. --- src/main/java/de/juplo/kafka/ApplicationConfiguration.java | 1 + src/main/java/de/juplo/kafka/ApplicationProperties.java | 1 + src/main/java/de/juplo/kafka/RestGateway.java | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 33dabc9..d9c7661 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -23,6 +23,7 @@ public class ApplicationConfiguration new RestGateway( properties.getClientId(), properties.getTopic(), + properties.getPartition(), kafkaProducer); } diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index a18b20f..2bcbb7a 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -22,6 +22,7 @@ public class ApplicationProperties @NotNull @NotEmpty private String topic; + private Integer partition; @NotNull @NotEmpty private String acks; diff --git a/src/main/java/de/juplo/kafka/RestGateway.java b/src/main/java/de/juplo/kafka/RestGateway.java index 4549b8f..c50f465 100644 --- a/src/main/java/de/juplo/kafka/RestGateway.java +++ b/src/main/java/de/juplo/kafka/RestGateway.java @@ -17,6 +17,7 @@ public class RestGateway { private final String id; private final String topic; + private final Integer partition; private final KafkaProducer producer; private long produced = 0; @@ -33,6 +34,7 @@ public class RestGateway final ProducerRecord record = new ProducerRecord<>( topic, // Topic + partition, // Partition - Uses default-algorithm, if null key, // Key value // Value ); -- 2.20.1