Schema Guard uses a Java Dynamic Proxy over the Kafka Producer to intercept messages before they reach the broker. If validation fails, a SchemaValidationException is thrown on the calling thread instantly.
1. Add Maven Dependency
<dependency>
<groupId>com.schemaguard</groupId>
<artifactId>schema-guard-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
1.1 Add GitHub Packages Repository (Required)
This artifact is published to GitHub Packages (not Maven Central). Add the repository and authenticate Maven.
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/nithinraaj27/kafka-schema-guard</url>
</repository>
</repositories>
<!-- ~/.m2/settings.xml -->
<settings>
<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>YOUR_GITHUB_TOKEN</password>
</server>
</servers>
</settings>
2. Configure application.properties
schema-guard.enabled=true
schema-guard.registry-url=https://api.your-registry.com/schemas
schema-guard.cache-ttl-minutes=60
# Map topics → schema IDs
schema-guard.topics.payment-events=your-schema-v1
schema-guard.topics.order-events=order-schema-v2
✅ Zero code changes in your existing services. Pure Auto-Configuration.