Assignment 03. RabbitMQ-Driven Order and Payment Workflow
Week 6 · Assignment brief from the course outline; submission and evaluation results have not been recorded.
Dependency: Extends A2 multi-container gateway
Scenario and assignment objective
Orders should be accepted quickly and then processed by separate background services instead of blocking an HTTP request.
Required system features
- Add RabbitMQ, a simulated Payment worker and a Notification consumer to Compose.
- Order POST returns 202/PENDING after durable order insert; publish OrderCreated message with event_id.
- Define event fields: event_id, event_type, order_id, correlation_id, occurred_at and payload.
- Payment worker applies a deterministic test success/failure rule, saves result and publishes PaymentProcessed.
- Notification consumer receives final event; persist or log a completion record.
- Use manual ACK after processing; bounded retries, dead-letter path and visible queue state.
Implementation guide - suggested steps
- Create a shared event schema document and service-specific consumers; choose a direct/topic exchange.
- Add RabbitMQ service with durable queue and management UI in Compose (development only).
- After Order DB write, publish OrderCreated (document that DB+publish dual-write remains an A3 risk).
- Write Payment consumer: handle event, simulate result, update persisted payment record, publish outcome.
- Write status-update handler/consumer in Order and notification consumer; expose GET /orders/{id}.
- Run a worker-failure experiment before ACK; verify redelivery and explain at-least-once behavior.
Hints (not complete solutions)
- Start with one queue and one consumer, then split event roles.
- Use manual ACK only after durable business state update; test crash before acknowledgement.
- An event_id is required now; A4 adds durable deduplication of repeated event_id.
- A DB write and broker publish are two separate operations; discuss a transactional outbox or reconciliation fix.
API / data contracts
- POST /orders returns 202 + order_id; GET /orders/{id} shows PENDING/CONFIRMED/REJECTED.
- Event envelope field names are stable; use routing keys such as order.created and payment.processed.
Mandatory verification and failure experiments
- Happy path PENDING -> CONFIRMED; rejected payment -> REJECTED.
- Stop Payment worker before ACK, then restart and observe broker redelivery.
- Send a deliberately malformed event and verify it is rejected/dead-lettered rather than repeatedly looping.
Required individual submission
- Updated Compose, event schema, workers, retry/dead-letter policy, sequence diagram.
- Automated workflow tests, queue monitoring evidence and limitation note on duplicate events.
Acceptance checklist
- Order workflow asynchronous and observable via polling endpoint.
- Worker interruption does not silently lose a message under stated settings.
- Documented at-least-once behavior and error handling.
Marks: 7 / 40 lab marks. Use the common rubric: implementation 40%, tests 25%, fault experiment 20%, documentation/viva 15%.