Thanks for the reviews, @dguy , @bbejeck , @viktorsomogyi , and @guozhangwang ,
As Guozhang said, this was really just intended to sketch out one way of doing "generic" serialization with Jackson, as it's cumbersome in practice to have a separate serde for every single type. I actually wasn't thinking that we'd merge this PR, just use it as a point of discussion. @guozhangwang I don't know about Thrift or Protobuf, but Avro requires a schema. I'm pretty sure you can't just feed it a random POJO and tell it to (de/)serialize it. I've always seen projects start with a schema and then generate their Java data classes. The data class actually contains the schema built in, and you register all the classes with the (de)serializer, so it can properly serialize objects according to their schema, and detect the right schema to deserialize with on the flip side. So, if I understand you question right, no, I don't think that there is one approach we can use for all serialization protocols. I suspect that each protocol will have its own corresponding algorithm. This is the inverse of what I was going for by including the Java class in the json. It's a low-fi version of the official way to accomplish this task in Jackson: https://fasterxml.github.io/jackson-annotations/javadoc/2.4/com/fasterxml/jackson/annotation/JsonTypeInfo.html To @bbejeck 's point, it may not be acceptable to see the class information in output topics, or for that matter, to require them in input topics. I have one idea about this, but it seems pretty brittle to me: if the key set is unique for each data class in the application, then the classes can all register their "signature" as the set of json keys they generate. Then the deserializer just has to extract the key set and look up the right class to deserialize to, et voila! Let me know if you'd rather see this POC'd. [ Full content available at: https://github.com/apache/kafka/pull/5590 ] This message was relayed via gitbox.apache.org for [email protected]
