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 withlocale (
str
) β The locale for the connection, default en-USproduct (
str
) β The product name for the connection, default aiorabbitloop (
typing.Optional
[asyncio.events.AbstractEventLoop
]) β Optionalasyncio
event loop to useon_return (
typing.Optional
[typing.Callable
]) β An optional callback method to be invoked if the server returns a published method. Can also be set using theregister_basic_return_callback()
method.ssl_context (
typing.Optional
[ssl.SSLContext
]) β Optionalssl.SSLContext
for the connection