q,ex,binding scaffolded
This commit is contained in:
@@ -24,66 +24,68 @@ By the end, you will have a real event flow running through RabbitMQ.
|
||||
## Lab Stack
|
||||
|
||||
- Language: **Python**
|
||||
- Broker: RabbitMQ (Docker)
|
||||
- Tooling: `uv`
|
||||
- Broker: RabbitMQ **4+** (Docker)
|
||||
- Library: `pika`
|
||||
|
||||
## Step 1: Project Setup (10 min)
|
||||
|
||||
- [ ] Create files:
|
||||
- [ ] `docker-compose.yml`
|
||||
- [ ] `requirements.txt`
|
||||
- [ ] `producer.py`
|
||||
- [ ] `worker.py`
|
||||
- [ ] `notifier.py`
|
||||
- [x] Create files:
|
||||
- [x] `docker-compose.yml`
|
||||
- [x] `pyproject.toml` (created by `uv init`)
|
||||
- [x] `producer.py`
|
||||
- [x] `worker.py`
|
||||
- [x] `notifier.py`
|
||||
|
||||
- [ ] Put this in `requirements.txt`:
|
||||
- [x] Initialize project and dependency with `uv`:
|
||||
|
||||
```txt
|
||||
pika==1.3.2
|
||||
```bash
|
||||
uv init --name rabbitmq-lab
|
||||
uv add pika==1.3.2
|
||||
```
|
||||
|
||||
- [ ] Put this in `docker-compose.yml`:
|
||||
- [x] Put this in `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
version: "3.9"
|
||||
services:
|
||||
rabbitmq:
|
||||
image: rabbitmq:3-management
|
||||
image: rabbitmq:4-management
|
||||
ports:
|
||||
- "5672:5672"
|
||||
- "15672:15672"
|
||||
```
|
||||
|
||||
- [ ] Start RabbitMQ:
|
||||
- [x] Start RabbitMQ:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
- [ ] Open UI: `http://localhost:15672` (`guest` / `guest`).
|
||||
- [x] Open UI: `http://localhost:15672` (`guest` / `guest`).
|
||||
|
||||
## Step 2: RabbitMQ Topology (15 min)
|
||||
|
||||
Create these resources from code (preferred) or UI:
|
||||
|
||||
- [ ] Exchange `orders.x` (direct)
|
||||
- [ ] Exchange `orders.dlx` (direct)
|
||||
- [ ] Queue `orders.q`
|
||||
- [ ] Queue `orders.processed.q`
|
||||
- [ ] Queue `orders.failed.q`
|
||||
- [ ] Queue `orders.dlq`
|
||||
- [x] Exchange `orders.x` (direct)
|
||||
- [x] Exchange `orders.dlx` (direct)
|
||||
- [x] Queue `orders.q`
|
||||
- [x] Queue `orders.processed.q`
|
||||
- [x] Queue `orders.failed.q`
|
||||
- [x] Queue `orders.dlq`
|
||||
|
||||
Bindings:
|
||||
|
||||
- [ ] `orders.q` <- `orders.x` with `order.created`
|
||||
- [ ] `orders.processed.q` <- `orders.x` with `order.processed`
|
||||
- [ ] `orders.failed.q` <- `orders.x` with `order.failed`
|
||||
- [ ] `orders.dlq` <- `orders.dlx` with `order.dead`
|
||||
- [x] `orders.q` <- `orders.x` with `order.created`
|
||||
- [x] `orders.processed.q` <- `orders.x` with `order.processed`
|
||||
- [x] `orders.failed.q` <- `orders.x` with `order.failed`
|
||||
- [x] `orders.dlq` <- `orders.dlx` with `order.dead`
|
||||
|
||||
Queue args for `orders.q`:
|
||||
|
||||
- [ ] `x-dead-letter-exchange=orders.dlx`
|
||||
- [ ] `x-dead-letter-routing-key=order.dead`
|
||||
- [x] `x-dead-letter-exchange=orders.dlx`
|
||||
- [x] `x-dead-letter-routing-key=order.dead`
|
||||
|
||||
## Step 3: Producer (20 min)
|
||||
|
||||
@@ -98,7 +100,7 @@ Queue args for `orders.q`:
|
||||
|
||||
Success check:
|
||||
|
||||
- [ ] Running `python producer.py` prints “Published order …” 5 times.
|
||||
- [ ] Running `uv run producer.py` prints “Published order …” 5 times.
|
||||
|
||||
## Step 4: Worker (35 min)
|
||||
|
||||
@@ -135,9 +137,9 @@ Success check:
|
||||
|
||||
Run in 3 terminals:
|
||||
|
||||
- [ ] Terminal A: `python worker.py`
|
||||
- [ ] Terminal B: `python notifier.py`
|
||||
- [ ] Terminal C: `python producer.py`
|
||||
- [ ] Terminal A: `uv run worker.py`
|
||||
- [ ] Terminal B: `uv run notifier.py`
|
||||
- [ ] Terminal C: `uv run producer.py`
|
||||
|
||||
Expected behavior:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user