From: Kai Moritz Date: Sun, 3 Nov 2024 10:23:15 +0000 (+0100) Subject: `buffer.memory` konfigurierbar gemacht X-Git-Tag: producer/spring-producer--2024-11-13--si X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fproducer%2Fspring-producer;p=demos%2Fkafka%2Ftraining `buffer.memory` konfigurierbar gemacht --- diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 3666233..7540dd3 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -42,6 +42,7 @@ public class ApplicationConfiguration 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("buffer.memory", properties.getProducerProperties().getBufferMemory()); props.put("batch.size", properties.getProducerProperties().getBatchSize()); props.put("metadata.max.age.ms", 5000); // 5 Sekunden props.put("request.timeout.ms", 5000); // 5 Sekunden diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index 594fa28..4323262 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -49,6 +49,8 @@ public class ApplicationProperties @NotNull private Duration maxBlock; @NotNull + private Long bufferMemory; + @NotNull private Integer batchSize; @NotNull private Duration linger; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4c6519d..98ea128 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,6 +6,7 @@ juplo: acks: -1 delivery-timeout: 10s max-block: 5s + buffer-memory: 33554432 batch-size: 16384 linger: 0 compression-type: gzip @@ -32,6 +33,7 @@ info: acks: ${juplo.producer.acks} delivery-timeout: ${juplo.producer.delivery-timeout} max-block: ${juplo.producer.max-block} + buffer-memory: ${juplo.producer.buffer-memory} batch-size: ${juplo.producer.batch-size} linger: ${juplo.producer.linger} compression-type: ${juplo.producer.compression-type}