add notifier

This commit is contained in:
2026-04-14 21:54:01 +00:00
parent 236a93d7b9
commit 0eeefa377d
3 changed files with 66 additions and 22 deletions
+21 -21
View File
@@ -104,47 +104,47 @@ Success check:
## Step 4: Worker (35 min)
- [ ] `worker.py` consumes from `orders.q` with manual ACK.
- [ ] For each message:
- [ ] Parse JSON
- [ ] Simulate processing (`sleep(1)`)
- [ ] If `should_fail` and `retry_count < 2`, republish same order with `retry_count + 1` to `order.created`, ACK original.
- [ ] If `should_fail` and `retry_count >= 2`, publish to `order.failed`, ACK original.
- [ ] Else publish to `order.processed`, ACK original.
- [x] `worker.py` consumes from `orders.q` with manual ACK.
- [x] For each message:
- [x] Parse JSON
- [x] Simulate processing (`sleep(1)`)
- [x] If `should_fail` and `retry_count < 2`, republish same order with `retry_count + 1` to `order.created`, ACK original.
- [x] If `should_fail` and `retry_count >= 2`, publish to `order.failed`, ACK original.
- [x] Else publish to `order.processed`, ACK original.
Important:
- [ ] Set `prefetch_count=1`.
- [ ] Use persistent publish for all outgoing messages.
- [x] Set `prefetch_count=1`.
- [x] Use persistent publish for all outgoing messages.
Success check:
- [ ] You see logs for retries and final outcomes.
- [x] You see logs for retries and final outcomes.
## Step 5: Notifier (15 min)
- [ ] `notifier.py` consumes both `orders.processed.q` and `orders.failed.q`.
- [ ] Print concise final messages, e.g.:
- [ ] `ORDER 1001 PROCESSED`
- [ ] `ORDER 1003 FAILED AFTER RETRIES`
- [ ] ACK all notifier messages.
- [x] `notifier.py` consumes both `orders.processed.q` and `orders.failed.q`.
- [x] Print concise final messages, e.g.:
- [x] `ORDER 1001 PROCESSED`
- [x] `ORDER 1003 FAILED AFTER RETRIES`
- [x] ACK all notifier messages.
Success check:
- [ ] After running producer, notifier shows both success and failure events.
- [x] After running producer, notifier shows both success and failure events.
## Step 6: End-to-End Run (10 min)
Run in 3 terminals:
- [ ] Terminal A: `uv run worker.py`
- [ ] Terminal B: `uv run notifier.py`
- [ ] Terminal C: `uv run producer.py`
- [x] Terminal A: `uv run worker.py`
- [x] Terminal B: `uv run notifier.py`
- [x] Terminal C: `uv run producer.py`
Expected behavior:
- [ ] Normal orders finish in `orders.processed.q` path.
- [ ] Failing orders retry 2 times then go `orders.failed.q`.
- [x] Normal orders finish in `orders.processed.q` path.
- [x] Failing orders retry 2 times then go `orders.failed.q`.
## Step 7: Failure Drill (10 min)