Kafka Streams物化商店构建错误 [英] Kafka Streams Materialized Store Build Error

查看:62
本文介绍了Kafka Streams物化商店构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在此处构建Materialized.as DSL代码: https://kafka.apache.org/11/javadoc/org/apache/kafka/streams/state/Stores.html

I'm trying to build the Materialized.as DSL code here: 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())

有人知道这里可能出什么问题吗?

Does anyone know what might be wrong here?

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类型不匹配.您需要指定类似

The problem is that builder.table does not know the generic type defaulting to <Object,Object>. Later, the Serde types don't match. You need to specify the types like

KTable<Long,String> dataStore = builder.<Long,String>table(
    "example_stream",
    Materialized.as(storeSupplier)
        .withKeySerde(Serdes.Long())
        .withValueSerde(Serdes.String()));

这篇关于Kafka Streams物化商店构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆