Nameko
https://github.com/nameko/nameko
Microservice example project using Python, RabbitMQ, Nameko and Flask
This a simple microservice sale and stock management system using:
- Python
- RabbitMQ
- Nameko
- Flask
Virtual Environment
- Python
- Nameko - www.nameko.io
- Flask
1
2
3
python -m venv microdemo
microdemo\Scripts\activate
pip3 install -r requirements.txt
You can run this command to see that all packages are installed.
1
pip3 list
Docker
The Docker Daemon must be startede (running) on your computer. You can do that by starting Docker Desktop.
RabbitMQ Docker
You have to download the RabbitMQ Docker image, run this command in a terminal:
1
docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management
You can access the RabbitMQ dashboard on http://localhost:15672/
- Username: guest
- Password: guest
Run service
Run this command in the terminal:
1
nameko run service --broker amqp://guest:guest@localhost
You can test the service by nameko shell:
1
nameko shell --broker amqp://guest:guest@localhost
Then run
1
n.rpc.sale.sell(1)
Run api
1
python api.py
The api is available on http://localhost:5000/