This demo mirrors the schemas used by the runnable spring-kafka-contract-demo and shows what the starter validates before the application is allowed to start.
The 0.2.0 starter supports Confluent modes NONE, BACKWARD, BACKWARD_TRANSITIVE, FORWARD, FORWARD_TRANSITIVE, FULL, and FULL_TRANSITIVE.
{
"type": "record",
"name": "OrderEvent",
"namespace": "io.github.mathias82.avro",
"fields": [
{ "name": "orderId", "type": "string" },
{ "name": "amount", "type": "double" },
{ "name": "createdAt", "type": "string", "default": "" }
]
}
{
"type": "record",
"name": "OrderEvent",
"namespace": "io.github.mathias82.avro",
"fields": [
{ "name": "orderId", "type": "string" },
{ "name": "amount", "type": "double" },
{ "name": "createdAt", "type": "string", "default": "" },
{ "name": "customerNote", "type": ["null", "string"], "default": null }
]
}
Adds an optional field with a default, so old data can still be read and old readers can ignore the new field.
{
"type": "record",
"name": "OrderEvent",
"namespace": "io.github.mathias82.avro",
"fields": [
{ "name": "orderId", "type": "string" },
{ "name": "status", "type": "string" }
]
}
Removes required fields and adds a required field without a default, so it breaks the contract.
The repository CI starts Kafka and Schema Registry, builds the starter under test, starts the Spring Boot demo, POSTs a unique order, and waits until the consumer exposes that exact event. This validates the full producer → Kafka → consumer path.