Production-oriented RabbitMQ integration for Flask, built on Pika
Project description
Documentation: https://flask-rmq.rdd-lab.com/
Source Code: https://github.com/RDDLab/Flask-RMQ
Flask-RMQ
Flask-RMQ provides typed RabbitMQ wrappers and tools for Flask applications using Pika.
It is not a task queue or a Celery replacement. It is a lightweight integration layer for services that need explicit message contracts, reliable publication, long-running consumers, topology management, and multiple independent RabbitMQ brokers.
Main features:
- standard Flask extension and app-factory integration;
- Click commands under the native
flask rmqCLI group; - separate thread-local producer and consumer connections;
- publisher confirms, persistent delivery, and
mandatory=Truerouting; - bounded producer retry and consumer exponential backoff;
- durable queues and dead-letter routing through
QueueConfig; - per-alias topology and consumer registries;
- optional Prometheus instrumentation;
- Python typing with a
py.typedmarker.
Installation
Install Flask-RMQ with pip or your preferred Python package manager:
pip install Flask-RMQ
Prometheus support is optional:
pip install 'Flask-RMQ[metrics]'
Flask-RMQ supports Python 3.10–3.14 and Flask 3.0–3.1.
Minimal application
import json
from flask import Flask
from flask_rmq import (
Consumer,
FlaskRMQ,
Producer,
get_consumers_registry,
get_setup_registry,
)
rmq = FlaskRMQ()
producer = Producer(queue='events')
consumer = Consumer(queue='events')
@consumer
def handle_event(channel, method, properties, body: bytes) -> None:
print(json.loads(body))
channel.basic_ack(delivery_tag=method.delivery_tag)
def setup_topology(channel) -> None:
channel.queue_declare(queue='events', durable=True)
def create_app() -> Flask:
app = Flask(__name__)
app.config['RABBITMQ_CONNECTIONS'] = {
'default': {'HOST': 'localhost'},
}
rmq.init_app(app)
with app.app_context():
get_setup_registry().register(setup_topology)
get_consumers_registry().register(consumer)
return app
flask --app your_app:create_app rmq check
flask --app your_app:create_app rmq setup
flask --app your_app:create_app rmq consume
Publish from a Flask route or service:
producer.publish(json.dumps({'event': 'created'}))
The complete runnable producer/consumer project is available in examples/basic_app.
Tests
python -m venv .venv
. .venv/bin/activate
pip install -e '.[dev,metrics]'
pytest
ruff check .
python -m build
The unit test suite does not require a live RabbitMQ broker. Use the example project for an end-to-end broker test.
Documentation portal
The VuePress portal contains complete English and Russian guides for configuration, producers, consumers, topology, CLI, reliability, metrics, the example project, and migration from Django-RMQ.
npm install
npm run docs:dev
npm run docs:build
MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_rmq-0.1.0.tar.gz.
File metadata
- Download URL: flask_rmq-0.1.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fd22d614e8cc26ae26feec6e711e2e3a18cf44fa95c7aac48caddc0ab5d28db
|
|
| MD5 |
a9778ad43c39c1ab62688f7e91daba10
|
|
| BLAKE2b-256 |
70d9ecc29fc0c04433051456af0865d5ffb084aa70cabeaa8206c1a9722627fe
|
Provenance
The following attestation bundles were made for flask_rmq-0.1.0.tar.gz:
Publisher:
publish.yml on RDDLab/Flask-RMQ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_rmq-0.1.0.tar.gz -
Subject digest:
8fd22d614e8cc26ae26feec6e711e2e3a18cf44fa95c7aac48caddc0ab5d28db - Sigstore transparency entry: 1998352640
- Sigstore integration time:
-
Permalink:
RDDLab/Flask-RMQ@8fcc95f5681588512b5e0853f4d73ad5cf805e3a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RDDLab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
publish.yml@8fcc95f5681588512b5e0853f4d73ad5cf805e3a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flask_rmq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flask_rmq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffe6093c8b9a768273b0dde7154412859ed1a3a1a82f383e7a7a5f017aa3bede
|
|
| MD5 |
d9f50daefef467e8d87eec085b5d0703
|
|
| BLAKE2b-256 |
16f0528a8f26af663aa0a6089ce540a7cd81fae2e62c152a13dbaa19678d87ee
|
Provenance
The following attestation bundles were made for flask_rmq-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on RDDLab/Flask-RMQ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_rmq-0.1.0-py3-none-any.whl -
Subject digest:
ffe6093c8b9a768273b0dde7154412859ed1a3a1a82f383e7a7a5f017aa3bede - Sigstore transparency entry: 1998352770
- Sigstore integration time:
-
Permalink:
RDDLab/Flask-RMQ@8fcc95f5681588512b5e0853f4d73ad5cf805e3a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RDDLab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
publish.yml@8fcc95f5681588512b5e0853f4d73ad5cf805e3a -
Trigger Event:
workflow_dispatch
-
Statement type: