MessageSender Class
A Message Sender that opens its own exclsuive Link on an existing Session.
- Inheritance
-
builtins.objectMessageSender
Constructor
MessageSender(session, source, target, name=None, send_settle_mode=SenderSettleMode.Unsettled, receive_settle_mode=ReceiverSettleMode.PeekLock, max_message_size=1048576, link_credit=None, properties=None, error_policy=None, debug=False, encoding='UTF-8', desired_capabilities=None)
Parameters
Name | Description |
---|---|
session
Required
|
The underlying Session with which to send. |
source
Required
|
The name of source (i.e. the client). |
target
Required
|
The AMQP endpoint to send to. |
name
|
A unique name for the sender. If not specified a GUID will be used. Default value: None
|
send_settle_mode
|
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. Default value: SenderSettleMode.Unsettled
|
receive_settle_mode
|
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. Default value: ReceiverSettleMode.PeekLock
|
desired_capabilities
|
The extension capabilities desired from the peer endpoint. To create a desired_capabilities object, please do as follows:
Default value: None
|
max_message_size
|
The maximum allowed message size negotiated for the Link. Default value: 1048576
|
link_credit
|
The sender Link credit that determines how many messages the Link will attempt to handle per connection iteration. Default value: None
|
properties
|
Metadata to be sent in the Link ATTACH frame. Default value: None
|
error_policy
|
A policy for parsing errors on link, connection and message disposition to determine whether the error should be retryable. Default value: None
|
debug
|
Whether to turn on network trace logs. If True, trace logs will be logged at INFO level. Default is False. Default value: False
|
encoding
|
The encoding to use for parameters supplied as strings. Default is 'UTF-8' Default value: UTF-8
|
Variables
Name | Description |
---|---|
send_settle_mode
|
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 send. If set to 'Settled', the client will not wait for confirmation and assume success. |
receive_settle_mode
|
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. |
max_message_size
|
The maximum allowed message size negotiated for the Link. |
Methods
close |
Close the sender, leaving the link intact. |
destroy |
Close both the Sender and the Link. Clean up any C objects. |
get_state |
Get the state of the MessageSender and its underlying Link. |
on_state_changed |
Callback called whenever the underlying Sender undergoes a change of state. This function can be overridden. |
open |
Open the MessageSender in order to start processing messages. |
send |
Add a single message to the internal pending queue to be processed by the Connection without waiting for it to be sent. |
work |
Update the link status. |
close
Close the sender, leaving the link intact.
close()
destroy
Close both the Sender and the Link. Clean up any C objects.
destroy()
get_state
Get the state of the MessageSender and its underlying Link.
get_state()
Returns
Type | Description |
---|---|
on_state_changed
Callback called whenever the underlying Sender undergoes a change of state. This function can be overridden.
on_state_changed(previous_state, new_state)
Parameters
Name | Description |
---|---|
previous_state
Required
|
The previous Sender state. |
new_state
Required
|
The new Sender state. |
open
Open the MessageSender in order to start processing messages.
open()
Exceptions
Type | Description |
---|---|
uamqp.errors.AMQPConnectionError if the Sender raisesan error on opening. This can happen if the target URI is invalidor the credentials are rejected.
|
send
Add a single message to the internal pending queue to be processed by the Connection without waiting for it to be sent.
send(message, callback, timeout=0)
Parameters
Name | Description |
---|---|
message
Required
|
The message to send. |
callback
Required
|
The callback to be run once a disposition is received in receipt of the message. The callback must take three arguments, the message, the send result and the optional delivery condition (exception). |
timeout
|
An expiry time for the message added to the queue. If the message is not sent within this timeout it will be discarded with an error state. If set to 0, the message will not expire. The default is 0. Default value: 0
|
work
Update the link status.
work()
Attributes
max_message_size
receive_settle_mode
send_settle_mode
Azure SDK for Python
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for