Skip to main content

robustmq-python

Python SDK for RobustMQ — mq9 AI-native async messaging.

Install

pip install robustmq

Requires Python 3.10+. The only runtime dependency is nats-py.

Quick start

import asyncio
from robustmq.mq9 import Client, Message

async def main():
    async with Client(server="nats://localhost:4222") as client:
        # Create a private mailbox (TTL 1 hour)
        mailbox = await client.create(ttl=3600)
        print(f"Mailbox: {mailbox.mail_id}")

        # Send a message
        await client.send(mailbox.mail_id, {"task": "summarize", "doc": "abc"})

        # Receive messages
        async def handler(msg: Message) -> None:
            print(f"[{msg.priority}] {msg.payload}")
            await client.delete(msg.mail_id, msg.msg_id)

        sub = await client.subscribe(mailbox.mail_id, handler)
        await asyncio.sleep(5)
        await sub.unsubscribe()

asyncio.run(main())

Worker pool (competitive consumption)

async with Client() as client:
    # Multiple workers share a queue group — each message goes to exactly one worker
    async def worker(msg: Message) -> None:
        print(f"Worker got: {msg.payload}")

    await client.subscribe("task.queue", worker, queue_group="workers")
    await asyncio.Future()  # run forever

Public mailbox discovery

async with Client() as client:
    mailboxes = await client.list_public()
    for mb in mailboxes:
        print(mb.mail_id, mb.desc)

API reference

Client(server, *, max_reconnect_attempts, reconnect_time_wait, request_timeout, name)

Parameter Default Description
server nats://localhost:4222 NATS server URL
max_reconnect_attempts 10 Auto-reconnect attempts (-1 = unlimited)
reconnect_time_wait 2.0 Seconds between reconnect attempts
request_timeout 5.0 Request/reply timeout in seconds

Methods

Method Description
await client.connect() Connect to server
await client.close() Drain and disconnect
await client.create(ttl, *, public, name, desc) Create mailbox → Mailbox
await client.send(mail_id, payload, *, priority) Send message
await client.subscribe(mail_id, callback, *, priority, queue_group) Subscribe → Subscription
await client.list(mail_id) List messages → list[Message]
await client.delete(mail_id, msg_id) Delete message
await client.list_public() Discover public mailboxes → list[Mailbox]

Client is also an async context manager (async with Client(...) as client).

Running tests

cd python
pip install -e ".[dev]"
pytest

No live server required — all tests use mocks.

Metadata

Release files for robustmq 1.0.0

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

Source distribution (sdist)

Source distribution for robustmq 1.0.0
File Size Uploaded
robustmq-1.0.0.tar.gz 7.4 kB Details

Built distribution (wheel)

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

Total release size: 13.5 kB

Release files / robustmq-1.0.0.tar.gz

Download URL robustmq-1.0.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6e29cd37ba0eae23faa943f15407c86dbc3fdcea6e2ed10010b164d449e96914
BLAKE2b-256 checksum
How to use checksums
19e66de1396d56465661205120504250013238a8724ec7f0649af6f4209a1853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / robustmq-1.0.0-py3-none-any.whl

Download URL robustmq-1.0.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73615777c8857004a49c80853415edde3f13cb92ce9f12210393701d4c73d8ca
BLAKE2b-256 checksum
How to use checksums
7fb90dd15acb4a4c8c9023891f1ff0a12d76d612eb745f55f900661bbbe1c0b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.3.5

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