This repository is part of the Kafka Contract Enforcement initiative:
- 🔧 Starter: https://github.com/mathias82/spring-kafka-contract-starter
- 🌐 Live Demo: https://mathias82.github.io/spring-kafka-contract-demo/
A fully runnable demo showcasing fail-fast Kafka Schema Registry contract validation using Spring Boot, Apache Kafka, Avro, and Confluent Schema Registry.
This project demonstrates how the
👉 spring-kafka-contract-starter
can prevent broken Kafka deployments by validating schema contracts at
application startup.
This demo answers a very practical question:
What actually happens when schemas are missing, incompatible, or evolve incorrectly in a real Spring Boot Kafka application?
It demonstrates:
- Kafka producer & consumer with Avro\
- Schema Registry subject creation\
- Schema evolution (compatible & incompatible)\
- Fail-fast application startup when contracts are broken\
- How startup validation prevents late production failures
This is not a library, but a reference project you can run, inspect, and experiment with.
Spring Boot Producer
↓
Apache Kafka
↓
Spring Boot Consumer
↓
PostgreSQL
Schema Registry (Avro)
↑
Contract validation at startup
- Java 17\
- Spring Boot 3.x\
- Apache Kafka\
- Confluent Schema Registry\
- Avro\
- PostgreSQL\
- Docker & Docker Compose
This demo is built to showcase:
👉 Spring Kafka Contract Starter
https://github.com/mathias82/spring-kafka-contract-starter
The starter enforces Kafka schema contracts before the application starts.
docker compose up -d
This starts Kafka, Schema Registry and PostgreSQL.
./mvnw spring-boot:run
- Application starts if schemas are valid\
- Application fails if a subject is missing or incompatible
Broken contracts = no startup.
kafka: contract: enabled: true compatibility: BACKWARD registry: type: confluent url: http://localhost:8081 subjects: - name: order-events-value schema-file: classpath:schemas/order-event.avsc
Medium article:
https://medium.com/@mstauroy/fail-fast-kafka-schema-contracts-in-spring-boot-before-production-breaks-1b080204b49e
Reddit discussion:
https://www.reddit.com/r/apachekafka/comments/1q43hs6/failfast_kafka_schema_registry_compatibility/
- Kafka + Schema Registry users\
- Spring Boot engineers using Avro\
- Teams dealing with schema evolution\
- Anyone bitten by late Kafka failures
This demo exists to make schema contracts visible and testable.
If you find it useful, check out the starter: https://github.com/mathias82/spring-kafka-contract-starter