java - Kafka Streams物化商店构建错误
问题描述
我正在尝试在这里构建 Materialized.as DSL 代码:https ://kafka.apache.org/11/javadoc/org/apache/kafka/streams/state/Stores.html
但我得到了错误
incompatible types: org.apache.kafka.common.serialization.Serde<java.lang.Long> cannot be converted to org.apache.kafka.common.serialization.Serde<java.lang.Object>
在线上
.withKeySerde(Serdes.Long())
有谁知道这里可能出了什么问题?
final StreamsBuilder builder = new StreamsBuilder();
KeyValueBytesStoreSupplier storeSupplier = Stores.inMemoryKeyValueStore("mystore");
KTable<Long,String> dataStore = builder.table(
"example_stream",
Materialized.as(storeSupplier)
.withKeySerde(Serdes.Long())
.withValueSerde(Serdes.String()));
解决方案
问题是builder.table
不知道泛型类型默认为<Object,Object>
. 后来,Serde 类型不匹配。您需要指定类型,例如
KTable<Long,String> dataStore = builder.<Long,String>table(
"example_stream",
Materialized.as(storeSupplier)
.withKeySerde(Serdes.Long())
.withValueSerde(Serdes.String()));
推荐阅读
- c++ - 将 ifstream 文件和每一行读入一个数组
- r - R: rbind 字符串到因子列
- salesforce - 从visualforce页面将静态/硬编码值传递给控制器
- amazon-web-services - 多种文件类型的 aws cloudfront 路径模式
- javascript - 反应 this.setState 问题
- html - 如何从后面的.vb代码中动态创建的HTML控件获取值
- javascript - 真的很简单的颜色选择器怎么导入呢?
- visual-studio-code - 打开硬盘驱动器时我的 vscode 覆盖 nautilus
- javascript - Vue JS:如何在简单的 Vue 示例中将复选框与相关选择绑定?
- r - 编辑 data.frame 中的每一行