Skip to content

filippoderosa84/SpringBootKafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Kafka Example

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.

Project Structure

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

Tech Stack

  • 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)

Services (Docker Compose)

Service Description Port
Kafka Message broker (KRaft mode) 9092
Kafdrop Kafka web UI 9000
PostgreSQL Relational database 5432
Adminer Database web UI 8080

Getting Started

Prerequisites

  • Docker & Docker Compose
  • Java 25+

1. Start the infrastructure

docker compose up -d

2. Run the Producer

cd kafka-example-producer
./gradlew bootRun

3. Run the Consumer

cd kafka-example-consumer
./gradlew bootRun

Modules

kafka-example-producer

A 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

kafka-example-consumer

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

Running Tests

From either module directory:

./gradlew test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages