说,我想从流中获得两个侧面输出,它的措辞很好,当只有一个侧面输出时,但是当我想要获得多个侧面输出时,Flink抛出了ClassCastException。
val input: DataStream[CanalModel] = see.addSource(consumer).name("FlinkKafkaConsumer")
val output1: OutputTag[CanalModel] = OutputTag[CanalModel]("store_goods")
val output2: OutputTag[CanalModel] = OutputTag[CanalModel]("store")
val drugStream = input
.process(new ProcessFunction[CanalModel, CanalModel] {
override def processElement(value: CanalModel, ctx: ProcessFunction[CanalModel, CanalModel]#Context, out: Collector[CanalModel]): Unit = {
if (value != null) {
if ("goods".equals(value.table)) {
out.collect(value)
} else if ("store_goods".equals(value.table)) {
ctx.output(output1, value)
} else if ("stores".equals(value.table)) {
ctx.output(output2, value)
}
}
}
})
Flink在下面抛出了异常:
java.lang.ClassCastException: scala.collection.immutable.HashMap$HashTrieMap cannot be cast to cn.uniondrug.analysis.model.StoreGoodsModel. Failed to push OutputTag with id 'store_goods' to operator. This can occur when multiple OutputTags with different types but identical names are being used.
如何解决问题?谢谢。