通过Spring访问Kafka Stream State Store

时间:2018-08-31 17:16:08

标签: apache-kafka apache-kafka-streams spring-kafka

参考本文档https://docs.spring.io/spring-kafka/reference/htmlsingle/#kafka-streams的4.2.6

如何使用kafka流弹簧支持访问州立商店?

没有春天,你能做吗?

StreamsBuilder builder = ...;
// Start an instance of the topology
KafkaStreams streams = new KafkaStreams(builder, config);

...

// Get the key-value store CountsKeyValueStore
ReadOnlyKeyValueStore<String, Long> keyValueStore =
    streams.store("CountsKeyValueStore", QueryableStoreTypes.keyValueStore());

但是我不确定如何获得KafkaStreams对象。

1 个答案:

答案 0 :(得分:2)

自动连接StreamsBuilderFactoryBean(或从应用程序上下文中获取对它的引用)并调用getKafkaStreams()