Wrapper for the PIKA for asyncio and humans.
Project description
Wrapper for the PIKA for asyncio and humans. See examples and the tutorial in documentation.
If you are newcomer in the RabbitMQ let’s start the adopted official RabbitMQ tutorial
Installation
pip install aio-pika
Usage example
import asyncio
from aio_pika import connect, Message
async def main(loop):
connection = await connect("amqp://guest:guest@127.0.0.1/", loop=loop)
queue_name = "test_queue"
routing_key = "test_queue"
# Creating channel
channel = await connection.channel()
# Declaring exchange
exchange = await channel.declare_exchange('direct', auto_delete=True)
# Declaring queue
queue = await channel.declare_queue(queue_name, auto_delete=True)
# Binding queue
await queue.bind(exchange, routing_key)
await exchange.publish(
Message(
bytes('Hello', 'utf-8'),
content_type='text/plain',
headers={'foo': 'bar'}
),
routing_key
)
# Receiving message
incoming_message = await queue.get(timeout=5)
# Confirm message
incoming_message.ack()
await queue.unbind(exchange, routing_key)
await queue.delete()
await connection.close()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
See another examples and the tutorial in documentation.
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
aio-pika-0.10.5.tar.gz
(14.8 kB
view details)
Built Distribution
aio_pika-0.10.5-py3-none-any.whl
(20.9 kB
view details)
File details
Details for the file aio-pika-0.10.5.tar.gz
.
File metadata
- Download URL: aio-pika-0.10.5.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6818f66172b815052d894cc27ae93f6d69ebbd97254b86aa5e209f6860bc059 |
|
MD5 | 3e4053849d1c3445287c9f9174b239d0 |
|
BLAKE2b-256 | e09bab52d3a797e09ed4611a82c534623cbdcc35fb80eb6d367435b14b32a8aa |
File details
Details for the file aio_pika-0.10.5-py3-none-any.whl
.
File metadata
- Download URL: aio_pika-0.10.5-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7aca387d2e23d162f6e84a743c8a44312bde9717197cb1d79d5d71ac6c11779e |
|
MD5 | 06fcc9ac4a7c3406adff7d42b0f1951b |
|
BLAKE2b-256 | 5f8533f9cacdc0e4bf68cd117e712a302a9880d906fc6c0caad6a0804954e626 |