Enterprise-ready Spring Boot application demonstrating Kafka integration with Avro serialization.
- ✅ Kafka Producer/Consumer with Avro serialization
- ✅ Error handling with Dead Letter Queue (DLQ)
- ✅ Retry mechanism with exponential backoff
- ✅ Health checks and monitoring (Actuator)
- ✅ Graceful shutdown
- ✅ Environment-specific configurations
- ✅ Integration tests with embedded Kafka
- ✅ Docker support
- ✅ Structured logging
# Start all services (Kafka, Schema Registry, Application)
docker-compose up -d
# Check application health
curl http://localhost:8080/actuator/health
# View logs
docker-compose logs -f weather-app# Start Kafka and Schema Registry
docker-compose up -d kafka schema-registry
# Run the application
./mvnw spring-boot:run -Dspring-boot.run.profiles=devKAFKA_BROKERS: Kafka bootstrap serversSCHEMA_REGISTRY_URL: Schema Registry URLKAFKA_SECURITY_PROTOCOL: Security protocol (SASL_SSL, etc.)KAFKA_SASL_MECHANISM: SASL mechanism (PLAIN, SCRAM-SHA-256, etc.)KAFKA_SASL_JAAS_CONFIG: JAAS configuration for authentication
dev: Development with debug loggingprod: Production with security and optimized settings
- Application:
http://localhost:8080/actuator/health - Kafka connectivity: Included in health check
- Actuator metrics:
http://localhost:8080/actuator/metrics - Kafka-specific metrics available
# Run all tests
./mvnw test
# Run integration tests only
./mvnw test -Dtest=*IntegrationTestProducer → Kafka Topic → Consumer
↓ ↓ ↓
Logging DLQ Error Handling
- Message processing fails
- Retry with exponential backoff (configurable attempts)
- If all retries fail, send to Dead Letter Queue
- Log error details for investigation
- Enable SASL/SSL for Kafka connections
- Use proper authentication mechanisms
- Secure Schema Registry access
- Set up alerts on DLQ message count
- Monitor consumer lag
- Track application health checks
- Increase consumer instances for higher throughput
- Partition topics appropriately
- Configure consumer group settings
- Create Avro schema in
src/main/avro/ - Run
mvn generate-sourcesto generate Java classes - Create producer/consumer services
- Add configuration and tests
- Follow Avro compatibility rules
- Test schema changes thoroughly
- Use Schema Registry compatibility settings