send.py
1 """ 2 Hello world `send.py` example implementation using aioamqp. 3 See the documentation for more informations. 4 5 """ 6 7 import asyncio 8 import aioamqp 9 10 11 @asyncio.coroutine 12 def send(): 13 transport, protocol = yield from aioamqp.connect() 14 channel = yield from protocol.channel() 15 16 yield from channel.queue_declare(queue_name='hello') 17 18 yield from channel.basic_publish( 19 payload='Hello World!', 20 exchange_name='', 21 routing_key='hello' 22 ) 23 24 print(" [x] Sent 'Hello World!'") 25 yield from protocol.close() 26 transport.close() 27 28 29 30 asyncio.get_event_loop().run_until_complete(send())