Bootstrap

【Flink】Flink-Kafka序列化反序列化

最简单的是SimpleStringSchema,对字符串进行序列化反序列化,这个Schema中既实现了了序列化,也实现了反序列化

new SimpleStringSchema()

union.addSink(new FlinkKafkaProducer011[String]("localhost:9092", "test", new SimpleStringSchema()))
val stream3 = env.addSource(new FlinkKafkaConsumer011[String]("sensor", new SimpleStringSchema(), properties))

自带自定义类型序列化与反序列化TypeInformationSerializationSchema,适用于输入和输出都是flink的形式,不过外部的kafka来了就不能用了,kafka  sink和source都是flink可以用,此例子中自定义pojo Student

TypeInformationSerializationSchema

val stream3 = env.addSource(new FlinkKafkaConsumer010[Student]("scy1", new TypeInformationSerializationSchema[Student](TypeInformation.of(classOf[Student]),env.getConfig) , properties))

value.addSink(new FlinkKafkaProducer010[Student]("192.168.12.101:21005", "scy1", new TypeInformationSerializationSchema[Student](Ty

;