RobustMQ Python SDK — unified messaging for AI, IoT, and data pipelines
Project description
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.
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 robustmq-0.3.5.tar.gz.
File metadata
- Download URL: robustmq-0.3.5.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f84f80c41ad4d54f9cfbfbb212ec9ac4e9a1e6dec2c0c133880a43e4df177aa
|
|
| MD5 |
24d2a7c610884f12a7d1b83b9b845d95
|
|
| BLAKE2b-256 |
177ab7815286ea278fa27fdce5ebee1463e070e9e5942f793a453271ad821e7e
|
File details
Details for the file robustmq-0.3.5-py3-none-any.whl.
File metadata
- Download URL: robustmq-0.3.5-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed55605c4d85cc81ef5b1371e761941257aad98b3a00834edbc35351e9ca3499
|
|
| MD5 |
1bdda11c27bb49b4ce8f12ad136fa05a
|
|
| BLAKE2b-256 |
f195b49374b3e857dd601fec67d33e9852acd3f2d0f02421eee0052cd711c8ed
|