Context ManagerΒΆ

connect() is an asynchronous context manager that returns a connected instance of the aiorabbit.client.Client class. When exiting the runtime context, the client connection is automatically closed.

aiorabbit.connect(url='amqp://guest:guest@localhost:5672/%2f', locale='en-US', product='aiorabbit/1.0.0a1', loop=None)[source]ΒΆ

Asynchronous context-manager that connects to RabbitMQ, returning a connected Client as the target.

Example UsageΒΆ
async with aiorabbit.connect(RABBITMQ_URL) as client:
     await client.exchange_declare('test', 'topic')
Parameters
  • url (str) – The URL to connect to RabbitMQ with

  • locale (str) – The locale for the connection, default en-US

  • product (str) – The product name for the connection, default aiorabbit

  • loop (typing.Optional[asyncio.events.AbstractEventLoop]) – Optional asyncio event loop to use