aioamqp icon indicating copy to clipboard operation
aioamqp copied to clipboard

Introduce a new api to consume message from Rabbit.

Open dzen opened this issue 5 years ago • 0 comments

The goal is to get rid of the callback, which is imho a non-sense in an asyncio context.

the new Channel::consume method now returns a MessageQueue objects which can be iterated using async for.

This object allows us to ease the API:

    x = channel.consume(queue_name='hello')
    await x.qos(prefetch_size=0, prefetch_count=1)
    async with x as consumer:
        async for message in consumer:
            body, envelope, properties = message
            await channel.basic_client_ack(delivery_tag=envelope.delivery_tag)

dzen avatar Mar 20 '20 10:03 dzen