AMQPClientAsync Class

An asynchronous AMQP client.

Inheritance
AMQPClientAsync

Constructor

AMQPClientAsync(remote_address, auth=None, client_name=None, loop=None, debug=False, error_policy=None, keep_alive_interval=None, **kwargs)

Parameters

remote_address
str, bytes or Address
Required

The AMQP endpoint to connect to. This could be a send target or a receive source.

auth
AMQPAuth
default value: None

Authentication for the connection. This should be one of the subclasses of uamqp.authentication.AMQPAuth. Currently this includes:

  • uamqp.authentication.SASLAnonymous

  • uamqp.authentication.SASLPlain

  • uamqp.authentication.SASTokenAsync

  • uamqp.authentication.JWTTokenAsync

If no authentication is supplied, SASLAnnoymous will be used by default.

client_name
str or bytes
default value: None

The name for the client, also known as the Container ID. If no name is provided, a random GUID will be used.

debug
bool
default value: None

Whether to turn on network trace logs. If True, trace logs will be logged at INFO level. Default is False.

error_policy
ErrorPolicy
default value: False

A policy for parsing errors on link, connection and message disposition to determine whether the error should be retryable.

keep_alive_interval
int
default value: None

If set, a thread will be started to keep the connection alive during periods of user inactivity. The value will determine how long the thread will sleep (in seconds) between pinging the connection. If 0 or None, no thread will be started.

max_frame_size
int
default value: None

Maximum AMQP frame size. Default is 63488 bytes.

channel_max
int
Required

Maximum number of Session channels in the Connection.

idle_timeout
int
Required

Timeout in milliseconds after which the Connection will close if there is no further activity.

properties
dict
Required

Connection properties.

remote_idle_timeout_empty_frame_send_ratio
float
Required

Ratio of empty frames to idle time for Connections with no activity. Value must be between 0.0 and 1.0 inclusive. Default is 0.5.

incoming_window
int
Required

The size of the allowed window for incoming messages.

outgoing_window
int
Required

The size of the allowed window for outgoing messages.

handle_max
int
Required

The maximum number of concurrent link handles.

on_attach
<xref:func>[Source, Target, dict, AMQPConnectionError]
Required

A callback function to be run on receipt of an ATTACH frame. The function must take 4 arguments: source, target, properties and error.

send_settle_mode
SenderSettleMode
Required

The mode by which to settle message send operations. If set to Unsettled, the client will wait for a confirmation from the service that the message was successfully sent. If set to 'Settled', the client will not wait for confirmation and assume success.

receive_settle_mode
ReceiverSettleMode
Required

The mode by which to settle message receive operations. If set to PeekLock, the receiver will lock a message once received until the client accepts or rejects the message. If set to ReceiveAndDelete, the service will assume successful receipt of the message and clear it from the queue. The default is PeekLock.

encoding
str
Required

The encoding to use for parameters supplied as strings. Default is 'UTF-8'

Methods

auth_complete_async

Whether the authentication handshake is complete during connection initialization.

client_ready_async

Whether the handler has completed all start up processes such as establishing the connection, session, link and authentication, and is not ready to process messages.

close_async

Close the client asynchronously. This includes closing the Session and CBS authentication layer as well as the Connection. If the client was opened using an external Connection, this will be left intact.

do_work_async

Run a single connection iteration asynchronously. This will return True if the connection is still open and ready to be used for further work, or False if it needs to be shut down.

mgmt_request_async

Run an asynchronous request/response operation. These are frequently used for management tasks against a $management node, however any node name can be specified and the available options will depend on the target service.

open_async

Asynchronously open the client. The client can create a new Connection or an existing Connection can be passed in. This existing Connection may have an existing CBS authentication Session, which will be used for this client as well. Otherwise a new Session will be created.

auth_complete_async

Whether the authentication handshake is complete during connection initialization.

async auth_complete_async()

Return type

client_ready_async

Whether the handler has completed all start up processes such as establishing the connection, session, link and authentication, and is not ready to process messages.

async client_ready_async()

Return type

close_async

Close the client asynchronously. This includes closing the Session and CBS authentication layer as well as the Connection. If the client was opened using an external Connection, this will be left intact.

async close_async()

do_work_async

Run a single connection iteration asynchronously. This will return True if the connection is still open and ready to be used for further work, or False if it needs to be shut down.

async do_work_async()

Return type

Exceptions

TimeoutError or uamqp.errors.ClientTimeout if CBS authentication timeout reached.

mgmt_request_async

Run an asynchronous request/response operation. These are frequently used for management tasks against a $management node, however any node name can be specified and the available options will depend on the target service.

async mgmt_request_async(message, operation, op_type=None, node=None, callback=None, **kwargs)

Parameters

message
Message
Required

The message to send in the management request.

operation
bytes or str
Required

The type of operation to be performed. This value will be service-specific, but common values include READ, CREATE and UPDATE. This value will be added as an application property on the message.

op_type
bytes
default value: None

The type on which to carry out the operation. This will be specific to the entities of the service. This value will be added as an application property on the message.

node
bytes or str
default value: None

The target node. Default is b"$management".

timeout
float
default value: None

Provide an optional timeout in milliseconds within which a response to the management request must be received.

callback
callable[int, bytes, Message]
Required

The function to process the returned parameters of the management request including status code and a description if available. This can be used to reformat the response or raise an error based on content. The function must take 3 arguments - status code, response message and description.

status_code_field
bytes or str
Required

Provide an alternate name for the status code in the response body which can vary between services due to the spec still being in draft. The default is b"statusCode".

description_fields
bytes or str
Required

Provide an alternate name for the description in the response body which can vary between services due to the spec still being in draft. The default is b"statusDescription".

Return type

open_async

Asynchronously open the client. The client can create a new Connection or an existing Connection can be passed in. This existing Connection may have an existing CBS authentication Session, which will be used for this client as well. Otherwise a new Session will be created.

async open_async(connection=None)

Parameters

connection
default value: None

An existing Connection that may be shared between multiple clients.

Attributes

loop