RabbitMQUtils
Example for reader
Consumer
from aio_rabbitmq_utils import RabbitMQConsumeInputDeviceManager, RabbitMQInputConsumeDevice
async def example():
input_device_manager = RabbitMQConsumeInputDeviceManager(
hosts=["the", "rabbit", "hosts", ", will", "connect", "to", "only", "one"],
user="user",
password="password",
vhost="/",
prefetch_count=10,
)
await input_device_manager.connect()
input_device: RabbitMQInputConsumeDevice = await input_device_manager.get_device("some_queue_name")
await input_device.connect()
data, headers, transaction = await input_device.read()
# do something
# To ack the message (remove from queue)
await transaction.commit()
# To nack the message (re-queue the message)
await transaction.rollback()
Basic Get
from aio_rabbitmq_utils import RabbitMQMultiConnectionBasicGetInputDeviceManager, RabbitMQInputBasicGetDevice
async def example():
input_device_manager = RabbitMQMultiConnectionBasicGetInputDeviceManager(
hosts=["the", "rabbit", "hosts", ", will", "connect", "to", "only", "one"],
user="user",
password="password",
vhost="/",
max_connections=10,
max_channels=50,
)
await input_device_manager.connect()
input_device: RabbitMQInputBasicGetDevice = await input_device_manager.get_device("some_queue_name")
await input_device.connect()
data, headers, transaction = await input_device.read()
# do something
# To ack the message (remove from queue)
await transaction.commit()
# To nack the message (re-queue the message)
await transaction.rollback()
Example for writer
from io import BytesIO
from aio_rabbitmq_utils import RabbitMQOutputDeviceManager, RabbitMQOutputDevice
async def example():
output_device_manager = RabbitMQOutputDeviceManager(
hosts=["the", "rabbit", "hosts", ", will", "connect", "to", "only", "one"],
user="user",
password="password",
vhost="/",
exchange_name="",
)
await output_device_manager.connect()
output_device: RabbitMQOutputDevice = await output_device_manager.get_device("some_routing_key")
await output_device.connect()
success = await output_device.send(
BytesIO(b"Hi"),
{"some": "headers"},
)
if success:
print("Message sent")
else:
raise Exception("Failed to send the message")
Metadata
Release files for aio-rabbitmq-utils 1.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aio_rabbitmq_utils-1.0.14.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aio_rabbitmq_utils-1.0.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / aio_rabbitmq_utils-1.0.14.tar.gz
| Download URL | aio_rabbitmq_utils-1.0.14.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe6727bf61fa37e9cf94a41d06a3a8a82e1ddc517ade8eb59f21d327a246f075
|
|
BLAKE2b-256 checksum How to use checksums |
942efed6d3ed0dc0ea365e2548af4dc6e36dd4697334fabd5622c654b5b9df00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Release files / aio_rabbitmq_utils-1.0.14-py3-none-any.whl
| Download URL | aio_rabbitmq_utils-1.0.14-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
457c57bfcbff6e49ee8518aa6db27df57f97ceec343db9062b0245d112a38c83
|
|
BLAKE2b-256 checksum How to use checksums |
3ad136c6f3f8897ee1ced89c0079c34a7c4b5859079b4fdf428014698a8ea4aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|