liveBook · Manning

Use.latest.version

As explained in Kafka Streams in Action, Second Edition

use.latest.version is a serializer configuration that selects the latest schema version registered for a subject.

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

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains schema selection and failure behavior, but does not provide a complete producer configuration listing.
Examples
Uses an Avro union of truck, plane, and delivery events registered under inventory-events-value.
What it assumes
Assumes familiarity with schema registration, subjects, Avro schemas, and schema references.
What you can do after
Operate Avro producers that serialize referenced event types through the registered union schema.
How it connects
Connects schema references, union schemas, auto.register.schemas, subject names, and Avro serializers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.