Welcome to the Pizzeria repository!
This project a simple example of implementing message queue system in a django application. It uses both tradational and message queue to process orders.
To set up the project, follow these steps:
-
Redis
sudo apt-get install redis redis-server --daemonize yes redis-cli ping ## PONG
-
Repository
git clone https://github.com/garvitgupta13/pizzeria.git cd pizzeria python -m venv .venv source .venv/bin/activate pip install -r requirements.txt python manage.py migrate python manage.py runserver
-
Run worker threads to process those orders (you can run multiple workers in different terminals), ensure redis is running
rq worker -c app.settings --with-scheduler
-
Run RQ Dashboard to monitor the worker threads
rq-dashboard
There are two endpoints to create orders:
- [POST]
/order/bulk-create/
- [POST]
/order/enqueue/
Hit the above endpoints with payload {"order_cnt": 10}
to create 10 orders.
First endpoint will linearly process the orders and return the response after creating all the orders.
Second endpoint will push the orders to the message queue and return response while the worker threads will process them in background.