Microservice developed to address the BTG Pactual challenge. The challenge involves creating a microservice that:
- Consumes data from a queue
- Stores this data in a database
- Provides functionality to:
- Retrieve the total amount of an order
- Get the total number of orders for a customer
- List orders made by a customer
- ✅ Java 21
- ✅ SpringBoot
- ✅ Spring Data MongoDB
- ✅ RabbitMQ
- ✅ Docker
- ✅ JUnit 5 + Mockito(unit tests)
- ✅ IntelliJ IDEA Community Edition 2023.2.2
- Clone the repository:
$ git clone https://github.com/Guilhermebit/btg-pactual-back-end-challenge.git
-
Install dependencies with Maven
-
Install docker: https://docs.docker.com/engine/install/
-
Run the following command:
./mvnw clean install
- Run the following command:
docker-compose up
- Access RabbitMQ at http://localhost:15672
- Login using the default credentials (usually
guest
/guest
). - Navigate to the "Queues" menu and select the relevant queue.
- Paste the provided payload from the challenge into the Payload field.
- Click on "Publish Message" to send the message to the queue.
- The API will be accessible at http://localhost:8081.
To test the HTTP requests, you can use Postman.
Download Postman here: https://www.postman.com/downloads/
GET /customers/{customerId}/orders
-
Response 200 (application/json)
-
Body
{ "data": [ { "orderId": 1001, "customerId": 1, "total": 120.00 } ], "pagination": { "page": 0, "pageSize": 10, "totalElements": 1, "totalPages": 1 } }
-
If you encounter issues, consider the following:
- Ensure all services are running properly in Docker.
- Check Docker logs for any errors related to RabbitMQ or MongoDB.
- Verify that the configuration files are correctly set up.