Skip to main content

A flexible MQTT routing framework with middleware support

Project description

logo.png

RouteMQ Framework

OpenSSF Scorecard

A flexible MQTT routing framework with middleware, dynamic routes, queue workers, Redis integration, and horizontal scaling — inspired by Laravel/Django web frameworks.

Quick Start

1. Install

pip install routemq[cli]

2. Scaffold a new project

routemq new my-app
cd my-app

The scaffolder asks about optional features (MySQL, Redis, background queue, Docker). Use --yes to accept defaults non-interactively.

3. Run

# Edit .env with your MQTT broker details
routemq run

Features

  • Dynamic Router Loading - Automatically discover and load routes from multiple files
  • Route-based MQTT topic handling - Define routes for MQTT topics
  • Middleware support - Process messages through middleware chains
  • Parameter extraction - Extract variables from MQTT topics using Laravel-style syntax
  • Background Task Queue - Laravel-style queue system for async job processing
  • Shared Subscriptions - Horizontal scaling with worker processes
  • Redis Integration - Optional Redis support for distributed caching and rate limiting
  • Advanced Rate Limiting - Multiple rate limiting strategies with Redis backend
  • Optional MySQL integration - Use with or without a database
  • Docker Support - Production-ready Docker Compose setup with queue workers
  • Environment-based configuration - Configuration through .env files

Documentation

Documentation is available in the docs folder, optimized for GitBook integration.

See the Installation Guide for detailed setup instructions.

Quick Links

Project Health

Project Structure

Scaffolded projects follow this layout:

my-app/
├── app/                    # Your application code
│   ├── controllers/        # Route handlers
│   ├── middleware/         # Custom middleware
│   ├── models/             # Database models
│   ├── jobs/               # Background jobs
│   └── routers/            # Route definitions
├── bootstrap/              # Application bootstrap
├── docker-compose.yml      # Optional Docker setup
├── pyproject.toml          # Project metadata and dependencies
└── .env                    # Environment configuration

Docker Deployment

RouteMQ can scaffold Docker support for Redis, MySQL, app runtime, and queue workers:

routemq new my-app --with-docker --with-redis --with-mysql --with-queue
cd my-app

# Start services from the scaffolded project
docker compose up -d

# View logs
docker compose logs -f

# Scale workers
docker compose up -d --scale queue-worker-default=5

See Docker Deployment Guide for detailed instructions.

Background Task Queue

Process time-consuming tasks asynchronously with the built-in queue system:

# Create a job
from routemq.job import Job

class SendEmailJob(Job):
    max_tries = 3
    queue = "emails"

    async def handle(self):
        # Send email logic
        pass

# Dispatch the job
from routemq.queue.queue_manager import dispatch

job = SendEmailJob()
job.to = "user@example.com"
await dispatch(job)

Run a worker from your scaffolded app:

routemq queue-work --queue emails

See Queue System Documentation for the complete guide.

Advanced: Fork the framework

If you want to modify the framework internals directly (rather than depend on the published wheel), see TEMPLATE.md. This path is deprecated as the primary workflow; pip install routemq[cli] is recommended for application development.

For direct framework development:

git clone https://github.com/ardzz/RouteMQ.git
cd RouteMQ
uv sync --all-extras --dev
uv run python run_tests.py

Contributing

We welcome contributions! Please see our documentation for development setup and contribution guidelines.

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

routemq-0.22.1.tar.gz (723.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

routemq-0.22.1-py3-none-any.whl (90.0 kB view details)

Uploaded Python 3

File details

Details for the file routemq-0.22.1.tar.gz.

File metadata

  • Download URL: routemq-0.22.1.tar.gz
  • Upload date:
  • Size: 723.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for routemq-0.22.1.tar.gz
Algorithm Hash digest
SHA256 5487cfa2260a2725bff4e235c05ab69c5eb9e1538212dc6ec32c758b3e4cb236
MD5 a0bc29005d226d1f37c752b6b2eb813e
BLAKE2b-256 44473d86017c2266e2e39e554700ff2d29f46c80c05f6d992ad4ee9d1121067c

See more details on using hashes here.

Provenance

The following attestation bundles were made for routemq-0.22.1.tar.gz:

Publisher: publish.yml on ardzz/RouteMQ

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file routemq-0.22.1-py3-none-any.whl.

File metadata

  • Download URL: routemq-0.22.1-py3-none-any.whl
  • Upload date:
  • Size: 90.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for routemq-0.22.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9682a014597d0ad15d9527a75cdb36747c52afe6d37630d72bd896b2a70fa4be
MD5 285b50aee8153e97ba4cc1c0d3d119ec
BLAKE2b-256 e6513ab2e074518a46077f52a33dced51bfd838ca137dbb8f52d5dc2c023f5be

See more details on using hashes here.

Provenance

The following attestation bundles were made for routemq-0.22.1-py3-none-any.whl:

Publisher: publish.yml on ardzz/RouteMQ

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page