A pure python, thread-safe, minimalistic and pythonic RabbitMQ client library
Project description
rabbitpy
A pure-Python, thread-safe, minimalistic RabbitMQ client library.
rabbitpy provides a straightforward API for working with RabbitMQ. Connections, channels, queues, exchanges, and messages are plain Python objects. The library handles the AMQP protocol details so you don't have to.
Installation
pip install rabbitpy
Requirements
- Python 3.11+
- RabbitMQ 3.8+
Quick start
Publish a message
import rabbitpy
with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
with conn.channel() as channel:
exchange = rabbitpy.Exchange(channel, 'my-exchange')
exchange.declare()
queue = rabbitpy.Queue(channel, 'my-queue')
queue.declare()
queue.bind(exchange, 'my-routing-key')
message = rabbitpy.Message(channel, 'Hello, world!')
message.publish(exchange, 'my-routing-key')
Consume messages
import rabbitpy
with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
with conn.channel() as channel:
for message in rabbitpy.Queue(channel, 'my-queue'):
print(message.body)
message.ack()
Get a single message
import rabbitpy
with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
with conn.channel() as channel:
queue = rabbitpy.Queue(channel, 'my-queue')
message = queue.get()
if message:
print(message.body)
message.ack()
Publish with confirmations
import rabbitpy
with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
with conn.channel() as channel:
channel.enable_publisher_confirms()
message = rabbitpy.Message(channel, 'Hello, world!')
if message.publish('', routing_key='my-queue'):
print('Confirmed by broker')
Transactional publishing
import rabbitpy
with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
with conn.channel() as channel:
tx = rabbitpy.Tx(channel)
tx.select()
message = rabbitpy.Message(channel, 'Hello, world!')
message.publish('', routing_key='my-queue')
tx.commit()
Simple one-liner API
For scripts and simple use cases, rabbitpy provides module-level functions that manage the connection and channel for you:
import rabbitpy
# Publish
rabbitpy.publish('amqp://localhost/%2f', routing_key='my-queue', body=b'hello')
# Get
message = rabbitpy.get('amqp://localhost/%2f', queue_name='my-queue')
# Consume
for message in rabbitpy.consume('amqp://localhost/%2f', queue_name='my-queue'):
print(message.body)
message.ack()
break
Connection URL
amqp[s]://username:password@host:port/virtual_host[?options]
Query string options:
| Option | Description |
|---|---|
heartbeat |
Heartbeat interval in seconds (default: 60) |
channel_max |
Maximum number of channels |
frame_max |
Maximum frame size in bytes |
timeout |
Connection timeout in seconds (default: 3) |
cacertfile |
Path to CA certificate file |
certfile |
Path to client certificate file |
keyfile |
Path to client certificate key |
verify |
Certificate verification: ignore, optional, or required |
Example: amqp://guest:guest@localhost:5672/%2f?heartbeat=30&timeout=5
Documentation
Full API documentation is available at https://gmr.github.io/rabbitpy/.
License
BSD 3-Clause. See LICENSE for details.
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 rabbitpy-3.0.1.tar.gz.
File metadata
- Download URL: rabbitpy-3.0.1.tar.gz
- Upload date:
- Size: 133.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0664ca146869215c602eafab69fccf63ad24710fcc4dd9c9c37b4b1e62fdb9c1
|
|
| MD5 |
bf96704718042cf9eddfd336d9a2633f
|
|
| BLAKE2b-256 |
1bbdeed7e03a150b042314260b480875be448dcb4c9c795f7d84d1db7cec8fba
|
Provenance
The following attestation bundles were made for rabbitpy-3.0.1.tar.gz:
Publisher:
deploy.yaml on gmr/rabbitpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabbitpy-3.0.1.tar.gz -
Subject digest:
0664ca146869215c602eafab69fccf63ad24710fcc4dd9c9c37b4b1e62fdb9c1 - Sigstore transparency entry: 1228651872
- Sigstore integration time:
-
Permalink:
gmr/rabbitpy@adda0d0ed08905637061b742cc789feda3afd2c4 -
Branch / Tag:
refs/tags/3.0.1 - Owner: https://github.com/gmr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yaml@adda0d0ed08905637061b742cc789feda3afd2c4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rabbitpy-3.0.1-py3-none-any.whl.
File metadata
- Download URL: rabbitpy-3.0.1-py3-none-any.whl
- Upload date:
- Size: 51.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a57a453e5add46b06acdd16ccfc592d2cd8a596c73e2d5763bba90d09c31b382
|
|
| MD5 |
00945180a748efcfc9074d14c861d35c
|
|
| BLAKE2b-256 |
6aa1b891dab4b162430cc927a956f5cf12d7570bd27871472a260a98df3578d0
|
Provenance
The following attestation bundles were made for rabbitpy-3.0.1-py3-none-any.whl:
Publisher:
deploy.yaml on gmr/rabbitpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabbitpy-3.0.1-py3-none-any.whl -
Subject digest:
a57a453e5add46b06acdd16ccfc592d2cd8a596c73e2d5763bba90d09c31b382 - Sigstore transparency entry: 1228651932
- Sigstore integration time:
-
Permalink:
gmr/rabbitpy@adda0d0ed08905637061b742cc789feda3afd2c4 -
Branch / Tag:
refs/tags/3.0.1 - Owner: https://github.com/gmr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yaml@adda0d0ed08905637061b742cc789feda3afd2c4 -
Trigger Event:
release
-
Statement type: