This project demonstrates a Spring Boot application integrated with Apache Kafka to handle event publishing.
- Spring Boot 3.2.0 with Java 17.
- Apache Kafka integration using Spring Kafka.
- REST API endpoints for publishing string messages and complex event data.
- Utilizes Lombok for reducing boilerplate code.
- Jackson datatype integration for Java time objects.
- JDK 17
- Docker and Docker Compose (for running Kafka and Zookeeper)
- Gradle
The project uses the following key dependencies and plugins:
- Spring Boot Starter Web
- Spring Kafka
- Lombok
- Jackson Datatype for JSR310 (Java Time API)
To build the application, run the following commands:
./gradlew clean
./gradlew build
Before running the application, we need to build the Docker images:
docker-compose build
Once the build process is complete, we can start the application along with Kafka and Zookeeper using Docker Compose:
docker-compose up -d
The application provides two main endpoints:
Endpoint: /publish
Method: POST
Parameter: event (String)
Usage:
curl -X POST http://localhost:8080/publish?event=your-event
Endpoint: /events
Method: POST
Body: EventRequestDTO JSON
Usage:
curl -X POST http://localhost:8080/events \
-H "Content-Type: application/json" \
-d '{
"title": "Your Title",
"description": "Your Description",
"startTime": "yyyy-MM-dd HH:mm:ss",
"endTime": "yyyy-MM-dd HH:mm:ss",
"location": "Your Location"
}'
docker-compose logs -f