运行Flink时出现ClassCastException

时间:2016-06-29 05:19:42

标签: apache-kafka apache-flink

使用flink-connector-kafka-0.9运行Flink时出现以下错误     连接器。

   Exception in thread "main" java.lang.ClassCastException: org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer cannot be cast to org.apache.flink.streaming.api.functions.source.SourceFunction
at com.dataartisans.ReadFromKafka.main(ReadFromKafka.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Initially I was able to fetch records from Kafka . But now getting the above error .

1 个答案:

答案 0 :(得分:1)

line.end()不是源函数,而是汇函数。制作人的任务是向Kafka发射元素。与此相反,FlinkKafkaProducer08是从Kafka读取数据的源函数。