From: Kai Moritz Date: Sun, 3 Nov 2024 08:48:46 +0000 (+0100) Subject: `delivery.timeout.ms` konfigurierbar gemacht X-Git-Tag: producer/spring-producer--2024-11-13--si~2 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=872a137c8ea0b54f17f5a63e27a39c92777dde01;p=demos%2Fkafka%2Ftraining `delivery.timeout.ms` konfigurierbar gemacht --- diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 5a9bd82..86c6726 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -40,9 +40,9 @@ public class ApplicationConfiguration props.put("bootstrap.servers", properties.getBootstrapServer()); props.put("client.id", properties.getClientId()); props.put("acks", properties.getProducerProperties().getAcks()); + props.put("delivery.timeout.ms", (int)properties.getProducerProperties().getDeliveryTimeout().toMillis()); props.put("batch.size", properties.getProducerProperties().getBatchSize()); props.put("metadata.max.age.ms", 5000); // 5 Sekunden - props.put("delivery.timeout.ms", 10000); // 10 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()); diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index ea7622e..5663211 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -45,6 +45,8 @@ public class ApplicationProperties @NotEmpty private String acks; @NotNull + private Duration deliveryTimeout; + @NotNull private Integer batchSize; @NotNull private Duration linger; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cb9930a..d9ff458 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,6 +4,7 @@ juplo: producer: topic: test acks: -1 + delivery-timeout: 10s batch-size: 16384 linger: 0 compression-type: gzip @@ -28,6 +29,7 @@ info: producer: topic: ${juplo.producer.topic} acks: ${juplo.producer.acks} + delivery-timeout: ${juplo.producer.delivery-timeout} batch-size: ${juplo.producer.batch-size} linger: ${juplo.producer.linger} compression-type: ${juplo.producer.compression-type}