A demo project showcasing a Kafka-based messaging system using Spring Boot. It consists of two independent Spring Boot applications — a producer and a consumer — backed by a PostgreSQL database, with Kafka running in KRaft mode.
SpringBootKafka/
├── docker-compose.yaml # Spins up Kafka, Kafdrop, PostgreSQL, and Adminer
├── kafka-example-producer/ # Spring Boot app exposing a REST API to publish Kafka messages
└── kafka-example-consumer/ # Spring Boot app that consumes Kafka messages and persists them
- Java 25
- Spring Boot 4.1.0-SNAPSHOT
- Apache Kafka 3.9.2 (KRaft mode — no Zookeeper)
- PostgreSQL (via Spring Data JPA)
- Gradle (build tool)
- Docker Compose (local infrastructure)
| Service | Description | Port |
|---|---|---|
| Kafka | Message broker (KRaft mode) | 9092 |
| Kafdrop | Kafka web UI | 9000 |
| PostgreSQL | Relational database | 5432 |
| Adminer | Database web UI | 8080 |
- Docker & Docker Compose
- Java 25+
docker compose up -dcd kafka-example-producer
./gradlew bootRuncd kafka-example-consumer
./gradlew bootRunA Spring Boot web application that exposes REST endpoints to publish messages to a Kafka topic. It also persists data to PostgreSQL via Spring Data JPA.
Key dependencies: spring-boot-starter-web, spring-boot-starter-kafka, spring-boot-starter-data-jpa, postgresql
A Spring Boot application that listens to a Kafka topic and processes incoming messages. It persists consumed data to PostgreSQL via Spring Data JPA.
Key dependencies: spring-boot-starter-kafka, spring-boot-starter-data-jpa, postgresql
From either module directory:
./gradlew test