A python client for RabbitMQ Streams
Project description
RabbitMQ Stream Python Client
A Python asyncio-based client for RabbitMQ Streams
This is a work in progress
Install
pip install rstream
Quick start
Publishing messages:
from rstream import Producer, Consumer
async with Producer('localhost', username='guest', password='guest') as producer:
await producer.create_stream('mystream')
for i in range(100):
await producer.publish('mystream', f'msg: {i}'.encode())
Consuming messages:
consumer = Consumer(
host='localhost',
port=5552,
vhost='/',
username='guest',
password='guest',
)
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, lambda: asyncio.create_task(consumer.close()))
def on_message(msg):
print('Got message:', msg)
await consumer.start()
await consumer.subscribe('mystream', on_message)
await consumer.run()
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
rstream-0.2.1.tar.gz
(13.4 kB
view hashes)
Built Distribution
rstream-0.2.1-py3-none-any.whl
(16.4 kB
view hashes)