A reactive Spring Boot application demonstrating Kafka message publishing and consuming using WebFlux.
- Reactive Kafka Producer and Consumer
- WebFlux endpoints
- Message validation
- Error handling
- Server-Sent Events (SSE) for real-time message consumption
- Java 17+
- Docker
- Maven
- Start Kafka using Docker:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install --cask docker
open /Applications/Docker.app
docker --version docker ps
User the cocker-compose.yml file to start Kafka and Zookeeper
docker-compose up -d
docker ps
docker logs
debugging kafka issues docker exec -it /bin/bash kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic demo-topic --from-beginning
Testing the application
mvn spring-boot:run
docker ps
docker logs
Publishing a message to the Kafka topic
curl -X POST http://localhost:8080/api/kafka/publish -H "Content-Type: application/json" -d '{"message": "Hello, Kafka!"}'
Consuming messages from the Kafka topic