Complete example project
Complete example project
The repository includes examples/basic_app. It demonstrates:
- the Flask app-factory pattern;
- topology registration and a direct exchange;
- HTTP JSON publication;
- a consumer writing received JSON to
consumed.jsonl; - explicit ack and a dead-letter queue;
- RabbitMQ via Docker Compose.
cd examples/basic_app
docker compose up -d
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
flask --app basic_app:create_app rmq check
flask --app basic_app:create_app rmq setupTerminal one:
flask --app basic_app:create_app rmq consumeTerminal two:
flask --app basic_app:create_app run --debug
curl -X POST http://127.0.0.1:5000/events \
-H 'Content-Type: application/json' \
-d '{"message":"hello"}'
tail -f consumed.jsonlThe HTTP response is 202 Accepted; the same event appears in consumed.jsonl. RabbitMQ Management is at http://localhost:15672, using guest / guest for this local example.
Stop with Ctrl+C and docker compose down.