From 9b175c581e8ad8e35f3c1bb69d2ed1c6f1558a5f Mon Sep 17 00:00:00 2001 From: Shikong <919411476@qq.com> Date: Tue, 25 Apr 2023 21:17:35 +0800 Subject: [PATCH] =?UTF-8?q?topic=20=E8=AE=BE=E7=BD=AE=E8=AF=BB=E5=8F=96/?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kafka/tests/KafkaConfigTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kafka-01/kafka-01-producer/src/test/java/cn/skcks/study/springcloud/kafka/tests/KafkaConfigTest.java b/kafka-01/kafka-01-producer/src/test/java/cn/skcks/study/springcloud/kafka/tests/KafkaConfigTest.java index e1dc8fb..dba0395 100644 --- a/kafka-01/kafka-01-producer/src/test/java/cn/skcks/study/springcloud/kafka/tests/KafkaConfigTest.java +++ b/kafka-01/kafka-01-producer/src/test/java/cn/skcks/study/springcloud/kafka/tests/KafkaConfigTest.java @@ -86,13 +86,23 @@ public class KafkaConfigTest { }); Collection configs = Arrays.asList( - new AlterConfigOp(new ConfigEntry("min.cleanable.dirty.ratio", "0.5"), AlterConfigOp.OpType.SET), - new AlterConfigOp(new ConfigEntry("unclean.leader.election.enable", "false"), AlterConfigOp.OpType.SET), - new AlterConfigOp(new ConfigEntry("retention.ms","86400000"), AlterConfigOp.OpType.SET) + new AlterConfigOp(new ConfigEntry("min.cleanable.dirty.ratio", "0.5"), AlterConfigOp.OpType.SET), + new AlterConfigOp(new ConfigEntry("unclean.leader.election.enable", "false"), AlterConfigOp.OpType.SET), + // 设置30秒过期 + new AlterConfigOp(new ConfigEntry("retention.ms", "30000"), AlterConfigOp.OpType.SET), + new AlterConfigOp(new ConfigEntry("segment.ms", "30000"), AlterConfigOp.OpType.SET) ); - AlterConfigsResult result = client.incrementalAlterConfigs(Collections.singletonMap(resource,configs)); + AlterConfigsResult result = client.incrementalAlterConfigs(Collections.singletonMap(resource, configs)); result.all().get(); + + describeConfigsResult = client.describeConfigs(Collections.singletonList(resource)); + describeConfigsResult.all().get().forEach((source, config) -> { + log.info("{} =>", source.name()); + config.entries().forEach(entry -> { + log.info("\t{} => {}", entry.name(), entry.value()); + }); + }); } } }