Reputation: 11
Does anyone know why a namespace change in an Avro schema using backwards compatibility would not trigger an error in confluent schema registry when adding a new version of a schema.
What happened was we registered a new version of a schema with a namespace change. While the producer was updated with the new code (new namespace) the consumer was not, triggering a de-serialization exception on each read.
Could not find class X specified in writer's schema whilst finding reader's schema for a Specific Record.
I would expect this to trigger an error when adding a new version of a schema into Confluent Schema Registry but it was not.
Upvotes: 1
Views: 699
Reputation: 191973
The namespace isn't part of the schema resolution spec. Mostly only field names and their types are.
https://avro.apache.org/docs/1.11.1/specification/#schema-resolution
Java, on the other hand, generates classes on the classpath for the namespace, so it is required there for JVM package generation.
Python Avro client does not care about namespaces, for example, since there is no such structure or concept of package visibility / scope.
The registry is not client specific, and namespaces aren't really used during registration any more than doc
comments or other metadata.
You'd fix your Java error by using aliases to refer to the "old" namespace name. Or, you can use GenericRecord, not a SpecificRecord type. Otherwise, you need to compile your consumer code to include the Avro producer's "writer schema". Ideally, you do this with a Maven dependency, rather than copy around AVSC files, otherwise, you can use Schema Registry Maven Plugin download
goal, alongside avro-maven-plugin to create the SpecificRecord type that the producer had registered.
Upvotes: 2