有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Kafka DSL Kstream>Ktable连接序列化编译错误

我试图根据这个kafka documentation实现这个连接

我不知道为什么这个连接不起作用

first try

首先,我传递了所有的值

without parameter 这里它试图强制泛型为Object类型,这是非常错误的

如果未加入序列化选项,我将收到此运行时异常:

Exception in thread "StreamAPP-stream-event-b3dc5fff-abee-4fa0-92f9-e1690f8fd152-StreamThread-1" org.apache.kafka.streams.errors.StreamsException: ClassCastException while producing data to topic StreamAPP-stream-event-KSTREAM-KEY-SELECT-0000000025-repartition. A serializer (key: org.apache.kafka.common.serialization.ByteArraySerializer / value: org.apache.kafka.common.serialization.ByteArraySerializer) is not compatible to the actual key or value type (key type: br.com.calebebrim.kafka.entities.stream.sharing.registry.StreamRegistryKey / value type: br.com.calebebrim.kafka.entities.stream.sharing.stream.Event). Change the default Serdes in StreamConfig or provide correct Serdes via method parameters (for example if using the DSL, #to(String topic, Produced<K, V> produced) with Produced.keySerde(WindowedSerdes.timeWindowedSerdeFrom(String.class)))

有人能帮我吗

谢谢


共 (1) 个答案

  1. # 1 楼答案

    解决了

    我发现连接操作不能转换数据

    所以,我之前只是应用了mapValues,比如:

    stream map values before join