use.latest.version=true tells the serializer to retrieve the subject’s latest registered schema for serialization. With Avro schema references, that latest schema is typically the union schema containing the allowed event types. section 3.6
Use this setting with referenced Avro schemas when:
- auto.register.schemas=false prevents the serializer from registering an individual event schema and overwriting the union schema. section 3.6
- use.latest.version=true makes serialization select the registered union schema instead of searching for the event type in the subject name. section 3.6
- Without it, serialization can fail because the individual event type is not found as the subject schema. section 3.6
Listing 3.37 Registering the all_events schema with references
subject('truck_event',
'src/main/avro/truck_event.avsc', 'AVRO') #1
subject('plane_event','src/main/avro/plane_event.avsc', 'AVRO')
subject('delivery_event','src/main/avro/delivery_event.avsc', 'AVRO')
subject('inventory-events-value',
'src/main/avro/all_events.avsc','AVRO') #2
.addReference("bbejeck.chapter_3.avro.TruckEvent",
"truck_event", 1) #3
.addReference("bbejeck.chapter_3.avro.PlaneEvent", "plane_event", 1)
.addReference("bbejeck.chapter_3.avro.DeliveryEvent", "delivery_event", 1)
Shows the referenced event schemas registered first, followed by the union schema that use.latest.version selects. section 3.6
