重复的全局状态存储目录

Duplicate Global state store directories

我有一个使用 spring-cloud-stream 库的 kafka 流处理应用程序。此应用程序利用 3 application.id 值来收听 3 个主题。对于这些输入主题中的 2 个,在处理数据后,我将消息推送到各自的输出主题,然后我使用它们来创建 GlobalKTables,如下所示:

                streamsBuilder.globalTable(firstSSTopic, Consumed.with(Serdes.String(), Serdes.String()),
                        Materialized.<String, String, KeyValueStore<Bytes, byte[]>>
                                as("ss-1")
                                .withKeySerde(Serdes.String())

                                .withValueSerde(Serdes.String()));


                streamsBuilder.globalTable(secondSSTopic, Consumed.with(Serdes.String(), Serdes.String()),
                        Materialized.<String, String, KeyValueStore<Bytes, byte[]>>
                                as("ss-2")
                                .withKeySerde(Serdes.String())

                                .withValueSerde(Serdes.String()));

那么,问题是,它使用什么 application.id 来消费来自 "firstSSTopic" 和 "secondSSTopic" 的数据?或者它只是作为没有任何组的独立消费者的 GlobalStreamThread?当我检查默认状态目录 (tmp/kafka-streams) 时,我可以在所有 3 个 application.id 目录下看到全局状态存储的 sst 和日志文件。我怎样才能避免这种情况?因为这将占用 3X 磁盘 space 并且可能会导致存储空间快速填满。

GlobalKTable 只能用作流-table 连接的右侧输入。

but couldn't understand why it would persist the same data within the same app instance at multiple places

这提供了使用 KStream 执行连接的能力,而无需重新分区输入流。

How can i avoid this?

您无法使用 GlobalKTable 来避免这种情况。