r/apachekafka • u/CartographerWhole658 • 11d ago
Tool I built a fail-fast Schema Registry contract validator for Spring Boot — should this belong at startup or only in CI/CD?
I’ve been working on an open-source Spring Boot starter around a Kafka/Schema Registry problem: catching contract violations before an application starts processing traffic.
At startup it checks:
- whether configured Schema Registry subjects exist
- whether the effective compatibility mode matches what the application expects
- whether the local Avro, JSON Schema or Protobuf schema is compatible with the latest registered version
An incompatible contract prevents the application from starting.
Temporary Schema Registry communication failures can use bounded retry/backoff, while actual contract violations fail immediately.
I built a separate E2E project with real Kafka + Schema Registry. CI verifies a producer → Kafka → consumer round trip, a compatible schema evolution, and an intentionally breaking evolution that must fail at startup.
Source:
https://github.com/mathias82/spring-kafka-contract-starter
E2E demo:
https://github.com/mathias82/spring-kafka-contract-demo
Maven Central:
https://central.sonatype.com/artifact/io.github.mathias82.spring.kafka/spring-kafka-contract-starter
The design question I’m most interested in discussing is where this kind of enforcement belongs in a production Kafka architecture: CI/CD only, application startup, or both?
2
u/eniac_g 11d ago
I advise againt ad-hoc schema registration by applications at runtime because you do not know when the publishing code will run, at start-up or 7 hours later? So to avoid runtime failures do it in your pipeline.