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', locale='en-US', product='aiorabbit/1.0.1', loop=None, on_return=None, ssl_context=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

  • on_return (typing.Optional[typing.Callable]) – An optional callback method to be invoked if the server returns a published method. Can also be set using the register_basic_return_callback() method.

  • ssl_context (typing.Optional[ssl.SSLContext]) – Optional ssl.SSLContext for the connection