SendClientAsync Class

An AMQP client for sending messages asynchronously.

Inheritance
SendClientAsync
SendClientAsync

Constructor

SendClientAsync(target, auth=None, client_name=None, loop=None, debug=False, msg_timeout=0, error_policy=None, keep_alive_interval=None, **kwargs)

Parameters

target
str, bytes or Target
Required

The target AMQP service endpoint. This can either be the URI as a string or a ~uamqp.address.Target object.

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.

msg_timeout
int
default value: False

A timeout in milliseconds for messages from when they have been added to the send queue to when the message is actually sent. This prevents potentially expired data from being sent. If set to 0, messages will not expire. Default is 0.

error_policy
ErrorPolicy
default value: 0

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.

send_settle_mode
SenderSettleMode
default value: None

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.

desired_capabilities
AMQPValue
Required

The extension capabilities desired from the peer endpoint. To create a desired_capabilities object, please do as follows:

    1. Create an array of desired capability symbols: capabilities_symbol_array = [types.AMQPSymbol(string)]
    1. Transform the array to AMQPValue object: utils.data_factory(types.AMQPArray(capabilities_symbol_array))
max_message_size
int
Required

The maximum allowed message size negotiated for the Link.

link_properties
dict
Required

Metadata to be sent in the Link ATTACH frame.

link_credit
int
Required

The sender Link credit that determines how many messages the Link will attempt to handle per connection iteration.

max_frame_size
int
Required

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.

encoding
str
Required

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

Methods

close_async

Close down the client asynchronously. No further messages can be sent and the client cannot be re-opened.

All pending, unsent messages will remain uncleared to allow them to be inspected and queued to a new client.

redirect_async

Redirect the client endpoint using a Link DETACH redirect response.

send_all_messages_async

Send all pending messages in the queue asynchronously. This will return a list of the send result of all the pending messages so it can be determined if any messages failed to send. This function will open the client if it is not already open.

send_message_async

Send a single message or batched message asynchronously.

wait_async

Run the client asynchronously until all pending messages in the queue have been processed.

close_async

Close down the client asynchronously. No further messages can be sent and the client cannot be re-opened.

All pending, unsent messages will remain uncleared to allow them to be inspected and queued to a new client.

async close_async()

redirect_async

Redirect the client endpoint using a Link DETACH redirect response.

async redirect_async(redirect, auth)

Parameters

redirect
LinkRedirect
Required

The Link DETACH redirect details.

auth
AMQPAuth
Required

Authentication credentials to the redirected endpoint.

send_all_messages_async

Send all pending messages in the queue asynchronously. This will return a list of the send result of all the pending messages so it can be determined if any messages failed to send. This function will open the client if it is not already open.

async send_all_messages_async(close_on_done=True)

Parameters

close_on_done
bool
default value: True

Close the client once the messages are sent. Default is True.

Return type

send_message_async

Send a single message or batched message asynchronously.

async send_message_async(messages, close_on_done=False)

Parameters

messages
Required

A message to send. This can either be a single instance of ~uamqp.message.Message, or multiple messages wrapped in an instance of ~uamqp.message.BatchMessage.

close_on_done
bool
default value: False

Close the client once the message is sent. Default is False.

Exceptions

uamqp.errors.MessageException if message fails to send after retry policyis exhausted.

wait_async

Run the client asynchronously until all pending messages in the queue have been processed.

async wait_async()