Schema evolution and upcasting
An order event store that upcasts rows of an earlier shape when it reads them, an Avro OrderPlaced published through the outbox under a registry compatibility rule, and a notification consumer that reads every release through SmallRye and Camel.
examples/18-schema-evolution-and-upcasting/ adds shippingPriority to OrderPlaced. order-service stores events with a schema_version, upcasts them on read and publishes Avro bytes through the outbox; notification-service reads the topic with the newest schema. It accompanies Schema evolution and upcasting.
It uses Quarkus, Hibernate ORM with Panache, Flyway, Quarkus REST, SmallRye Reactive Messaging, the Apicurio Avro serdes, the Debezium outbox extension and Event Router, Camel Kafka for the comparison reader, PostgreSQL, Apicurio Registry and OpenTelemetry to the LGTM stack.
cd examples/18-schema-evolution-and-upcasting
mvn -B verify
./verify.sh
What to observe
- Old rows load as the current shape. A row stored without
shippingPriorityreads asSTANDARD, and its stored payload keeps the same checksum after a command. - The registry holds the contract. Versions 1 and 2 are accepted and version 3, which drops the default, is refused with 400.
- A refused command leaves nothing. The broken release answers 503 and stores no row, no record and no version.
- Both readers resolve both shapes. SmallRye and the Camel route record the same priorities from records written with versions 1 and 2.
Infrastructure
Kafka, PostgreSQL, Apicurio Registry, Connect and the LGTM stack from examples/_infra, plus order-service and notification-service. The compose project is edp-18.