From 99293f72c8469f9b27fbdbe8f1e60cdf9bfeabc8 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 3 Nov 2024 11:20:42 +0100 Subject: [PATCH] `max.block.ms` konfigurierbar gemacht --- src/main/java/de/juplo/kafka/ApplicationConfiguration.java | 2 +- src/main/java/de/juplo/kafka/ApplicationProperties.java | 2 ++ src/main/resources/application.yml | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 86c6726..3666233 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -41,10 +41,10 @@ public class ApplicationConfiguration props.put("client.id", properties.getClientId()); props.put("acks", properties.getProducerProperties().getAcks()); props.put("delivery.timeout.ms", (int)properties.getProducerProperties().getDeliveryTimeout().toMillis()); + props.put("max.block.ms", (int)properties.getProducerProperties().getMaxBlock().toMillis()); props.put("batch.size", properties.getProducerProperties().getBatchSize()); props.put("metadata.max.age.ms", 5000); // 5 Sekunden props.put("request.timeout.ms", 5000); // 5 Sekunden - props.put("max.block.ms", 5000); // 5 Sekunden props.put("linger.ms", properties.getProducerProperties().getLinger().toMillis()); props.put("compression.type", properties.getProducerProperties().getCompressionType()); props.put("key.serializer", StringSerializer.class.getName()); diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index 5663211..594fa28 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -47,6 +47,8 @@ public class ApplicationProperties @NotNull private Duration deliveryTimeout; @NotNull + private Duration maxBlock; + @NotNull private Integer batchSize; @NotNull private Duration linger; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d9ff458..4c6519d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,6 +5,7 @@ juplo: topic: test acks: -1 delivery-timeout: 10s + max-block: 5s batch-size: 16384 linger: 0 compression-type: gzip @@ -30,6 +31,7 @@ info: topic: ${juplo.producer.topic} acks: ${juplo.producer.acks} delivery-timeout: ${juplo.producer.delivery-timeout} + max-block: ${juplo.producer.max-block} batch-size: ${juplo.producer.batch-size} linger: ${juplo.producer.linger} compression-type: ${juplo.producer.compression-type} -- 2.20.1