How dilipsundarraj1/kafka-for-developers-using-spring-boot works
Project type and purpose
• This is an event-driven, two-microservice demo built with Spring Boot and Apache Kafka.
• “library-events-producer” exposes a REST API to publish “LibraryEvent” messages to Kafka topics.
• “library-events-consumer” consumes those messages, processes them (with manual-offset control, retry scheduler, error handling) and persists into an H2 database via JPA.
File structure
• Top-level folders:
• library-events-producer (a Spring Boot producer service)
• library-events-consumer (a Spring Boot consumer service)
• Each service contains:
• src/main/java/com/learnkafka – code packages (config, controller/producer/consumer/service/jpa/entity)
• application.yml – environment & Kafka settings
• CI: .github/workflows/gradle.yml
• Docs: SetUpKafka*.md, Kafka_Security.md
README for insights
• Confirms core use-case: Kafka producers/consumers demo
• Mentions SSL security, H2 console (http://localhost:8081/h2-console)
Main components and interactions
a. Components
• Client (e.g., curl, Postman)
• Producer Service (“library-events-producer”):
• REST Controller
• Kafka Producer component
• Auto-topic creation config
• Kafka Cluster (secured via SSL/TLS)
• Consumer Service (“library-events-consumer”):
• KafkaListener implementations (auto/manual offset, retry consumer)
• RetryScheduler
• Business services
• JPA repositories (LibraryEvents, FailureRecord)
• H2 Database (in-memory)
b. Relationships & data flow
1. Client → HTTP POST/PUT → Producer Controller
2. Controller → LibraryEventProducer → Kafka topic
3. Kafka Broker → delivers messages to consumer group
4. Consumer → onMessage → Service → JPA Repo → H2 DB (LibraryEvents table)
5. On processing failures → FailureRecord table + RetryScheduler triggers re-processing
c. Architectural patterns/design principles
• Asynchronous, event-driven pub/sub
• Spring Boot microservices
• Manual offset management for at-least-once semantics
• Retry with scheduler for transient errors
• Separation of concerns: controller, producer/consumer, service, repository
d. Key technologies
• Spring Boot, Spring Kafka
• Apache Kafka (SSL/TLS secured cluster)
• H2 database
• JPA/Hibernate
• Gradle, GitHub Actions CI
Detailed elements
• Service names (LibraryEventsProducerApplication, LibraryEventsConsumerApplication)
• Config components (AutoCreateConfig, LibraryEventsConsumerConfig)
• Kafka topics and security (SSL/TLS config)
• RetryScheduler and FailureRecord path
• H2 console endpoint
Final advice
• Call out key architectural patterns (pub/sub, manual offset, retry) in notes