Schema-aware AMQP client for the RocketMQ broker — Pydantic + aio-pika.
Project description
rocketmq.py
Schema-aware AMQP client for the RocketMQ broker - Pydantic v2 + aio-pika.
Python port of the rocketmq.js TypeScript SDK.
Setup
Requires uv.
uv sync # install deps + editable package
Quick Start
import asyncio
from rocketmq import connect
from rocketmq.schema import BaseSchema
class Order(BaseSchema):
id: str
customer_id: str
qty: int
async def main():
mq = await connect(url="amqp://localhost")
orders = await mq.queue("orders", Order)
await orders.send(Order(id="1", customer_id="c1", qty=5))
await orders.consume(lambda msg: print(msg))
await asyncio.sleep(2)
await mq.close()
asyncio.run(main())
Development
make help # show all commands
make fmt # format (ruff)
make lint # lint (ruff)
make typecheck # type-check (pyright)
make test # run tests (pytest)
make check # lint + typecheck + test
make all # format + fix + typecheck + test
Architecture
src/rocketmq/
├── __init__.py # Public re-exports
├── py.typed # PEP 561 marker
├── amqp.py # Thin aio-pika wrapper
├── client.py # RocketMQ + connect() + QueueHandle
├── schema.py # BaseSchema + Proto annotation
├── proto.py # Pydantic model -> proto3 string
├── serializer.py # Serializer Protocol + JsonSerializer
├── errors.py # Error hierarchy
├── error_codes.py # BrokerErrorCode enum
└── error_parser.py # Broker JSON error parsing
Cross-Language Type Compatibility
Python types map to proto3 types that match the JS SDK:
| Python | TypeScript (Zod) | Proto3 |
|---|---|---|
str |
z.string() |
string |
int |
z.number() |
double |
float |
z.number() |
double |
bool |
z.boolean() |
bool |
bytes |
z.object(...) |
bytes |
datetime |
z.date() |
Timestamp |
Annotated[int, Proto("int32")] |
z.number().int() |
int32 |
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
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 rocketmq_sdk-0.1.0.tar.gz.
File metadata
- Download URL: rocketmq_sdk-0.1.0.tar.gz
- Upload date:
- Size: 72.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1626eedb2a6c05f9c4b4f266a8150e9278445a483459669f10baafc16986b70
|
|
| MD5 |
30cb4b787596e53972ed459a44413114
|
|
| BLAKE2b-256 |
72b0a258e62409fb1b97e03ffe526721b907137850cd608f18ee6d318fdda851
|
Provenance
The following attestation bundles were made for rocketmq_sdk-0.1.0.tar.gz:
Publisher:
publish.yml on rocketmq-broker/rocketmq.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocketmq_sdk-0.1.0.tar.gz -
Subject digest:
a1626eedb2a6c05f9c4b4f266a8150e9278445a483459669f10baafc16986b70 - Sigstore transparency entry: 1738750381
- Sigstore integration time:
-
Permalink:
rocketmq-broker/rocketmq.py@67bac0ce05abb693cdeadd67d34bb23e3440a3a9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rocketmq-broker
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67bac0ce05abb693cdeadd67d34bb23e3440a3a9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rocketmq_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rocketmq_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 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 |
f5d0d067572a4194a29250ea85b92d73a5dec85b8c004658131ff1834c740d57
|
|
| MD5 |
769da6d1c223892e3e53fddd17850370
|
|
| BLAKE2b-256 |
24d5df14b38f3995cd7cc63e49d7e944a596f1996c377a42de470f69c7c31d98
|
Provenance
The following attestation bundles were made for rocketmq_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on rocketmq-broker/rocketmq.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocketmq_sdk-0.1.0-py3-none-any.whl -
Subject digest:
f5d0d067572a4194a29250ea85b92d73a5dec85b8c004658131ff1834c740d57 - Sigstore transparency entry: 1738750389
- Sigstore integration time:
-
Permalink:
rocketmq-broker/rocketmq.py@67bac0ce05abb693cdeadd67d34bb23e3440a3a9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rocketmq-broker
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67bac0ce05abb693cdeadd67d34bb23e3440a3a9 -
Trigger Event:
release
-
Statement type: