【发布时间】:2020-01-21 05:54:26
【问题描述】:
kafka 流的配置:
threads = 1;
replicationFactor = 1;
ktableCommitInterval= 10000;
ktableMemory=72000000;
timeDuration=10;
拓扑:
KStream<Windowed<String>,String> windowedStringKStream =
streamsBuilder.stream(inputTopic, Consumed.with(Serdes.String(),Serdes.String()))
.groupByKey(Grouped.with(Serdes.String(),Serdes.String()))
.windowedBy(TimeWindows.of(Duration.ofSeconds(timeDuration)).grace(Duration.ofSeconds(0)))
.reduce(Numners::append,Materialized.<String, String, WindowStore<Bytes,byte[]>>as(storeName).withCachingEnabled().withRetention(Duration.ofSeconds(timeDuration)).withKeySerde(Serdes.String()).withValueSerde(Serdes.String()))
.toStream();
代码说明:
Code appends numbers in a 10 Second window. Incremental Number records are sent exactly at a interval of 1 second into input topic.
问题:
提交间隔设置为 10 秒。缓存大小设置为 72 MB。数据以字节为单位。状态存储已启用缓存。文档指出,将数据推送到下游的 kafka 流的操作语义取决于缓存大小或提交间隔,无论首先发生什么。但根据实验,提交在一分钟内发生两次。观察是提交间隔在应用程序启动时开始,但在数据开始时开始窗口。如图所示,中间窗口结果被推送,最终窗口结果也被推送。
对于我正在处理的用例,无法使用 Suppress(),因为如果没有关于该主题的新数据,它将不会刷新数据。
任何帮助将不胜感激。如果有人遇到这种情况或想重现这种情况,请告诉我。
【问题讨论】:
标签: java apache-kafka apache-kafka-streams windowing