我是 kafka 和 kafka 流的新手。我有一个与 kafka 生产者、消费者、KStream 和 KTable 一起工作的基本 Spring 服务。现在,我想检查我的 KTable 记录,因此为了实现它,我正在尝试使用 Kafka Query API。
这可以通过以下方式实现(没有 Spring 集成):
KafkaStreams streams = new KafkaStreams(topology, config);
// Get access to the custom store
MyReadableCustomStore<String,String> store = streams.store("the-custom-store", new MyCustomStoreType<String,String>());
// Query the store
String value = store.read("key");
Run Code Online (Sandbox Code Playgroud)
现在,我尝试使用基于 Spring 的 InteractiveQueryService 来进行查询……但是我在 Spring 启动中遇到了一些依赖问题。
在 Spring 中使用 kafka 查询 API 的最佳方法是什么?
我的服务中的 Spring kafka 配置如下所示:
@Bean("streamsBuilder")
public StreamsBuilderFactoryBean recordsStreamBuilderFactoryBean() {
Map<String, Object> config = new HashMap<>();
// set some properties …Run Code Online (Sandbox Code Playgroud)