首页 > 解决方案 > 带有内部 RocksDB 状态存储的 Kafka 流应用程序无法获取密钥的数据

问题描述

我有一个运行 36 个不同实例(每个分区一个)的 kafka 流应用程序。我正在状态之上建立休息服务来访问数据。

这里有一些代码来访问数据

StreamsMetadata metadata = streams.metadataForKey(store, key, serializer); --> call this find ouy which host has the key
if (localSelf.host().equals(hostStoreInfo.getHost())) {
get the key from local store
}
else {
call the remote host using restTemplate

现在的问题是metadata返回的对象具有不同的主机/IP,但数据位于不同的节点上。我能够看到使用我打印的一些应用程序日志。

allMetadataon 方法说,当重新分配分区时,该KafkaStreams值将被更新。但它不会发生以防万一。我能做什么。

标签: apache-kafkaapache-kafka-streamsstream-processing

解决方案


推荐阅读