This project is an example of how to use RabbitMQ and Go to process exchange rates.
The project consists of three main parts:
-
Server (API): A Go API that receives requests to fetch exchange rates.
-
Sender (Sender): Sends exchange rate responses to a message broker.
-
Worker (Worker): A Go worker that consumes messages from a message broker, fetches exchange rates, and sends the results back to the API.
Before running the project, you need to create a free account at CurrencyFreaks to obtain an API access key.
Create a .env file in the api folder with the following content:
API_KEY=YOUR_API_KEY
-
Start RabbitMQ (In case you're using it over AmazonSQS):
# Latest RabbitMQ 3.12 docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.12-management
-
Start the Worker:
go run ./workers/worker.go
-
Start the Server:
go run ./api/server.go
Make a GET request to the API at the following URL:
http://localhost:8080/latest?currency=USD
Replace USD with the desired currency.
Feel free to contribute to this project. Just open an issue or send a pull request. License
This project is licensed under the MIT License.