Skip to main content

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

rocketmq_sdk-0.1.0.tar.gz (72.6 kB view details)

Uploaded Source

Built Distribution

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

rocketmq_sdk-0.1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

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

Hashes for rocketmq_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a1626eedb2a6c05f9c4b4f266a8150e9278445a483459669f10baafc16986b70
MD5 30cb4b787596e53972ed459a44413114
BLAKE2b-256 72b0a258e62409fb1b97e03ffe526721b907137850cd608f18ee6d318fdda851

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocketmq_sdk-0.1.0.tar.gz:

Publisher: publish.yml on rocketmq-broker/rocketmq.py

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

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

Hashes for rocketmq_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5d0d067572a4194a29250ea85b92d73a5dec85b8c004658131ff1834c740d57
MD5 769da6d1c223892e3e53fddd17850370
BLAKE2b-256 24d5df14b38f3995cd7cc63e49d7e944a596f1996c377a42de470f69c7c31d98

See more details on using hashes here.

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

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