Consumer utility for AMQP
Project description
aioamqp-consumer-best
Usage
import asyncio
from typing import List
from aioamqp_consumer_best import (
ConnectionParams,
Consumer,
Exchange,
Message,
ProcessBulk,
Queue,
QueueBinding,
ToBulks,
load_json,
)
async def callback(messages: List[Message]) -> None:
print(messages)
consumer = Consumer(
middleware=(
load_json
| ToBulks(max_bulk_size=10, bulk_timeout=3.0)
| ProcessBulk(callback)
),
prefetch_count=10,
queue=Queue(
name='test-queue',
bindings=[
QueueBinding(
exchange=Exchange('test-exchange'),
routing_key='test-routing-key',
),
],
),
connection_params=[ # Round robin
ConnectionParams(),
ConnectionParams.from_string('amqp://user@rmq-host:5672/'),
],
)
asyncio.get_event_loop().run_until_complete(consumer.start())
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
Close
Hashes for aioamqp-consumer-best-1.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9da72d6db8885cc489fe323ade09a1442c7b391b4b7ddc50636bac523e06a1f2 |
|
MD5 | 7515a541e500fff89bf80f76529ae856 |
|
BLAKE2b-256 | a9e2b16c3fce031639ce8cb6278d4f2c6264cf898a7918fc1c8de8d1a4311e80 |
Close
Hashes for aioamqp_consumer_best-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8fe309e1d045651ca10c48a5dff00e4f0d92bc1adc23b5553e71c3904bb8287 |
|
MD5 | daa59fdd2eb700084f16a263f0f952d8 |
|
BLAKE2b-256 | bd3f3643b64abf1b41b5a3eccd79419e61d4d7f66e1174a96793b15c1194d7f4 |