Skip to main content

mqkit

Introduction

mqkit is a Python framework for creating apps that integrate with message brokers like RabbitMQ. It provides a FastAPI-style interface to accelerate the development of queue-based services.

Documentation

Complete documentation will be coming soon.

Usage

Multi-thread, single process example

from typing import Dict

from mqkit import App, Attributes, create_engine

app: App = App()


@app.on_start
def on_start() -> None:
    print("App is starting")


@app.queue("my_queue", forward_to="other_queue")
def my_queue_handler(message: Dict, attributes: Attributes) -> Dict:
    print(f"Received {message} with attributes {attributes}")
    return {"hello": "other queue!"}


@app.queue("other_queue")
def other_queue_handler(message: Dict, attributes: Attributes) -> None:
    print(f"Other queue received {message}")


app.run(create_engine("amqp://user:password@your-server:5672/"))

Single-thread, single process example

The blocking single-threaded @consume decorator is intended for situations where orchestration is handled by an external provider. (Think Kubernetes or Docker)

from typing import Dict

from mqkit import Attributes, consume


@consume("my_queue")
def handler(message: Dict, attributes: Attributes) -> None:
    print(f"Got message {message}")


# NOTE: The engine URL can be inferred here based on the MQKIT_ENGINE_URL
# environment variable. If you don't want to use the environment variable,
# pass an Engine instance as the `engine` parameter to @consume

Parameter models

mqkit also supports automatic serialization and validation of queue messages using Pydantic BaseModel classes. The appropriate models to use are inferred based on the annotations of the handler method:

from datetime import datetime

from mqkit import Attributes, consume
from pydantic import BaseModel


class ChatMessage(BaseModel):
    id: int
    user: str
    content: str
    sent_time: datetime


@consume("chat_messages")
def handler(message: ChatMessage, attributes: Attributes) -> None:
    print(f"Got chat message {message!r} with attributes {attributes}")


"""
Invalid messages raise exceptions and don't call the handler:

'invalid message' -> DecodeError
{}                -> ValidationError
{"id": 123}       -> ValidationError

Valid messages will result in the handler being called:
{
    "id": 123,
    "user": "will",
    "content": "hello!",
    "sent_time": "2026-03-09T11:51:09"
} -> Outputs the message with print()
"""

Note that a BaseModel annotation may also be added to the return parameter which will enforce that return values are of that type.

Metadata

Release files for mqkit 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mqkit 0.1.8
File Size Uploaded
mqkit-0.1.8.tar.gz 44.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mqkit 0.1.8
File Interpreter ABI Platform
mqkit-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 118.4 kB

Release files / mqkit-0.1.8.tar.gz

Download URL mqkit-0.1.8.tar.gz
Size 44.3 kB
Tags Source
SHA-256 checksum
How to use checksums
473adabab7a17ca8d4fc62ad55c1254f7db4966467c08781d267113b8525c538
BLAKE2b-256 checksum
How to use checksums
f74b1659e5bb9b6363267d28f83a07c0475a697e971e125b4d9a50b5a81e5579
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.14.2 Linux/6.18.9-arch1-2

Release files / mqkit-0.1.8-py3-none-any.whl

Download URL mqkit-0.1.8-py3-none-any.whl
Size 74.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43de249e3a64399a702e4937d3c5fd0fdf52fbb619cce85d0674cf261b30a160
BLAKE2b-256 checksum
How to use checksums
346bf6c2476e47f5ec6eedce2f32c35872458c4c2e94fad09480d34543970854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.14.2 Linux/6.18.9-arch1-2

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page