问题
I just want to know what is the best approach to handle json deserialisation errors while consuming data.
Lets say, my producer added below Json to topic:
{ "name":"John", "age":30 }
Later on producer changed the format of Json and now it started to add below message:
{ "surname":"Smith", "Country":"USA", "car":null }
On the other side I have Consumer which has Pojo with the fields name and age. Obviously my consumer(JsonDeserializer) is going to fail while deserialising second message.
Here is the question, how should I handle those kind of schema changes on the code side ? PreConditions:
I don't want to just log error or send those undeserilised messages to other topic.
I don't want to use Avro.
Only JsonDeserializer is allowed
Maybe the main question should be "if it is possible to save schemas of my Json messages to topic so that later if the format of message changes I would know how to deserialise them"
来源:https://stackoverflow.com/questions/57191872/kafka-jsondeserializer-fails-what-to-do