Skip to main content

nuropb-rmq

CI PyPI License Python Status

Async-native Python AMQP 0-9-1 client for RabbitMQ — built on asyncio, with no pika (or other AMQP client) at runtime. It implements connection/channel framing directly and layers nuropb-inspired JSON-RPC 2.0 mesh patterns (RPC, events, service bind, claims) on that transport. Protocol and session behaviour are backed by SpeC++ CheckSat and Lean proofs, not only tests.

Alpha: the public API may still change. See CHANGELOG.md.

Features

  • Asyncio-first API (await connect, publish, consume, RPC)
  • Native AMQP transport: connect, channel, declare, publish, consume, ack
  • Session RPC with exclusive reply queues and correlation tracking
  • Event pub/sub (JSON-RPC notification shape) over topic/fanout
  • Mesh service bind under a namespaced identity (service.method)
  • Optional JWT claims on RPC ([claims] extra)
  • TLS (tls-verify-full), mTLS / SASL EXTERNAL, PEM + PKCS#12 + secrets hook
  • Named queue profiles (durable-at-least-once default) and heartbeat watchdog
  • Fail-fast reconnect (CONNECTION_LOST); caller rebinds mesh consumers
  • Mandatory publish / basic.return (PublishReturned) so misrouted RPC is an error
  • Optional mesh discovery registry (announce/viewer — never a bind authority)
  • Runnable LangChain tool + LangGraph remote-node examples over the mesh
  • Throughput harness vs pika ([bench] extra)

Installation

Python 3.11+:

pip install nuropb-rmq
Extra Purpose
(none) Core client
claims JWT mesh claims (PyJWT)
pkcs12 PKCS#12 TLS material (cryptography)
bench pika comparison harness
pip install "nuropb-rmq[claims]"

From a known Git tag (or before a version is on PyPI):

pip install "git+https://github.com/RileyBetts/nuropb-rmq.git@v0.5.0"

Pushing an annotated v* tag from main publishes to PyPI via .github/workflows/publish.yml. Release checklist: CHANGELOG.md.

Quick start

Needs a local RabbitMQ broker (default 127.0.0.1:5672, guest/guest).

import asyncio
from nuropb_rmq import AmqpConnection, ConnectionConfig

async def main() -> None:
    conn = AmqpConnection(ConnectionConfig(host="127.0.0.1", port=5672))
    await conn.connect()
    ch = await conn.open_channel(1)
    queue = await conn.queue_declare(ch, "nr.ex.hello", durable=True)
    await conn.basic_consume(ch, queue)
    await conn.basic_publish(
        ch,
        b"hello-nuropb-rmq",
        routing_key=queue,
        properties={"content_type": "text/plain", "delivery_mode": 2},
    )
    msg = await conn.receive(timeout=5)
    print(msg.body)
    await conn.basic_ack(ch, msg.delivery_tag)
    await conn.close()

asyncio.run(main())

Prefer copy-paste demos? See Examples below. Stable imports: from nuropb_rmq import Session, RpcClient, MeshService, … (api.py).

Examples

Transport

Mesh

Framework adapters (self-standing uv projects — LangChain/LangGraph deps stay out of the root package)

  • examples/langchain_example/ — LangChain agent calling a mesh service tool (orders.get_status); live agent needs an LLM key, --smoke does not
  • examples/langgraph_example/ — LangGraph remote invoice extract over mesh RPC; optional reconnect_demo.py for CONNECTION_LOST → rebind → checkpoint replay

Smoke examples (with uv after uv sync --dev; also uv sync in examples/langchain_example and examples/langgraph_example):

./scripts/smoke_examples.sh

Documentation

User guides (config, AMQPS, mesh, claims): docs/

Design notes for contributors: thinking/architecture.md. Lean ↔ Python map: specs/lean/CORRESPONDENCE.md. Release notes: CHANGELOG.md.

Formal verification

Correctness work is part of the project, not an afterthought:

  • SpeC++ SMT CheckSat under specs/specpp/ (Protocol, Session, Pattern, Phase 2, Config)
  • Lean proofs under specs/lean/ (Protocol, Session, Pattern, Config, reconnect)

Contributor commands to run these gates are in CONTRIBUTING.md.

TLS, mesh, reconnect (summary)

from nuropb_rmq import MeshRegistryViewer, MeshService, ServiceIdentity

mesh = MeshService(cfg, identity=ServiceIdentity("orders"), methods=["ping"], announce=True)
await mesh.start()

Throughput vs pika

uv sync --dev --extra bench
uv run python -m bench.compare --quick

Contributing

PRs target development. Use uv for the maintainer environment (uv sync --dev). Branching, CI gates, SpeC++, and Lean commands: CONTRIBUTING.md.

License

Apache License 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nuropb_rmq-0.5.0.tar.gz (53.2 kB view details)

Uploaded Source

Built Distribution

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

nuropb_rmq-0.5.0-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file nuropb_rmq-0.5.0.tar.gz.

File metadata

  • Download URL: nuropb_rmq-0.5.0.tar.gz
  • Upload date:
  • Size: 53.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nuropb_rmq-0.5.0.tar.gz
Algorithm Hash digest
SHA256 595ebb731e0d6ef33769a89a37c5287c10eeda3b7e4d96031cc00fae4dc7f008
MD5 0162f5eeb31d86be7e8d278292833db6
BLAKE2b-256 9aec8c2c2e84c04b0d2660639298b4af23f1c994d0a82637716cea09f9d59d1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nuropb_rmq-0.5.0.tar.gz:

Publisher: publish.yml on RileyBetts/nuropb-rmq

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

File details

Details for the file nuropb_rmq-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: nuropb_rmq-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 67.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nuropb_rmq-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65ab8b2adb947c9cf5adabb7b61938c3d68f3646af1900104c137656ec932043
MD5 6848742227ccf2e359d4b4813843a1ed
BLAKE2b-256 636ac0237f279da935411192a07a287fcccdd340aba8c7041a29eda42e8b3204

See more details on using hashes here.

Provenance

The following attestation bundles were made for nuropb_rmq-0.5.0-py3-none-any.whl:

Publisher: publish.yml on RileyBetts/nuropb-rmq

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 Sentry Error logging StatusPage Status page