This project uses Event-Driven Architecture with Java 17, Spring Boot 3 and Kafka.
Two microservices were created, ms-kafka-producer and ms-kafka-consumer. Both communicate with Kafka through Spring Boot to create and access topics and partitions.
- Clone the repository:
git clone https://github.com/jonasfschuh/kafka-spring.git
-
Install dependencies with Maven
-
Install Docker
-
Install Offset Explorer
-
Install Postman
- Start docker containers, through the Docker folder
docker-compose up
To stop docker containers, use:
docker-compose down
- Configure Offset Explorer for Kafka (9092) and Zookeeper (2181) ports.
Note: Kakfa can be accessed directly via IntelliJ
- Start the application ms-kafka-producer with Maven or through the Services tab in intelliJ.
- The producer API will be accessible at http://localhost:8080/
- Access Postman and post a request.
Example
{
"code": "2008",
"productName": "Toyota Camry XLE V6",
"value": "60000.00"
}
- Start the application ms-kafka-consumer with Maven or through the Services tab in intelliJ.
The API provides the following endpoints:
POST /api/save-order - Register an event in Kafka. In this case, a purchase order.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request to the repository.
When contributing to this project, please follow the existing code style, commit conventions, and submit your changes in a separate branch.