Why is it not recommended to use JSONKeyValueDeserializationSchema

In the previous article, KafkaDeserializationSchema was used when deserializing Kafka data. Because I want to obtain the metadata information of Kafka, some students asked me why I didn't use Flink's own JSONKeyValueDeserializationSchema directly? This can also be obtained from Kafka. The metadata information of, and it is very simple to use.JSONKeyValueDeserializationSchema can indeed get the metadata information of kafka, but it has some limitations. Let's analyze the source code and you will understand.

JSONKeyValueDeserializationSchema source code analysis

Insert picture description here

From the figure above, you can see that the JSONKeyValueDeserializationSchema class also implements the KafkaDeserializationSchema interface, and then overwrites the three methods of destroy isEndOfStream getProducedType. Let’s look at the source code implementation of the JSONKeyValueDeserializationSchema class.

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed w

Guess you like

Origin blog.csdn.net/xianpanjia4616/article/details/108420596