问题
While producing AVRO data to Kafka, Avro serializer writing the same schema ID in the byte array which is used while writing the data.
Kafka Consumer fetches the schema from Schema Registry based on schema ID in the byte array received. So same schema ID is used in both i.e. Producer and Consumer and so the schema.
But why many article including this one says The consumer's schema could differ from the producer's.
Please help me in understanding this.
回答1:
Kafka Consumer fetches the schema from Schema Registry based on schema ID
Only if you let the deserializer do that.
You're capable of defining your own, compatible schema in the consumer code. Therefore, it could be different and follows the rules of Avro schema evolution
schema evolution happens only during deserialization at the consumer (read). If the consumer’s schema is different from the producer’s schema, then the value or key is automatically modified during deserialization to conform to the consumer's read schema if possible.
来源:https://stackoverflow.com/questions/52356783/in-schema-registry-consumers-schema-could-differ-from-the-producers-what-act