Search code examples
apache-kafkaavrokafka-producer-apiconfluent-schema-registry

In schema registry, consumer's schema could differ from the producer's, what actually it means


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.


Solution

  • 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.