This project aims to study and implement the Clean Architecture pattern using Spring and RabbitMQ as a means of communication. It consists of two applications:
- Student Registration: A simple application that allows users to register as students.
- Email Service: A service that listens to a RabbitMQ queue and sends an email whenever a new student is registered.
The project also includes a Docker Compose file to easily start all the required components.
- Spring Boot: Java framework for creating microservices.
- Clean Architecture: Software design pattern that promotes separation of concerns.
- RabbitMQ: Message broker for asynchronous communication between applications.
- Docker: Platform for building, shipping, and running applications in containers.
To run the project, follow these steps:
- Install Docker and Docker Compose.
- Clone the repository:
git clone https://github.com/ikk1/microservices.git
- Go to the project directory:
cd microservices
- Build and start the applications with Docker Compose:
docker-compose up
Send a POST request to http://localhost:8080/students
with the following request body format:
{
"name": "Student Name",
"email": "[email protected]",
"address": "Student Address",
"course": "MATH"
}
Replace the values as needed. The course field should be one of the following options: MATH, SCIENCE, HISTORY, or ENGLISH, indicating the student's course.
Make a GET request to http://localhost:8080/students to retrieve a list of all registered students.
It will return a list of students in the following format:
[
{
"id": 1,
"name": "Student Name",
"email": "[email protected]",
"address": "Student Address",
"course": "MATH"
},
{
"id": 2,
"name": "Another Student Name",
"email": "[email protected]",
"address": "Another Student Address",
"course": "SCIENCE"
},
...
]
Note: The Email Service application is not accessible via a web browser. It runs in the background and listens to the RabbitMQ queue. The email is sent to the address specified in student registration.
If you find this project useful, feel free to contribute by:
- Reporting bugs or suggesting improvements.
- Submitting pull requests with your changes.
This project is licensed under the MIT License.
- Clean Architecture: Uncle Bob's Blog
- Spring Boot: Official Website
- RabbitMQ: Official Website
- Docker: Official Website
This is a basic example of microservices using Clean Architecture and Spring. For more information on these topics, please refer to the resources mentioned above.
If you have any questions or feedback, please feel free to contact me at [email protected].