Configure the serializer
SpecificRecord or GenericRecord
Avro gives you two ways to represent a record in Java, and the choice affects how schema changes reach your code.SpecificRecord
Generate a class from an.avsc file with the Avro Maven plugin, and work with typed getters and
setters:
GenericRecord
Work with the schema at runtime, addressing fields by name:Compatibility rules
Avro compatibility follows the Avro schema resolution rules. The practical version:
Defaults are what make evolution work. A field with no default gives a reader nothing to fall
back on when the writer’s data omits it, so almost every safe addition is an addition with a default.
To rename a field without breaking readers, keep the old name as an alias:
BACKWARD. See
Evolution and compatibility.
Logical types
Avro logical types—timestamp-millis, decimal, uuid, date—annotate a primitive with
semantic meaning:
Schema references
Avro references a schema by its fully qualified record name. See Schema references.Normalization
?normalize=true performs real normalization for Avro, so schemas differing only in field ordering
or whitespace resolve to the same schema ID.
Next steps
Protobuf
Field numbers, imports, and null handling.
JSON Schema
Open content models and per-construct compatibility.