MessageReceiver Class

A Message Receiver that opens its own exclsuive Link on an existing Session.

Inheritance
builtins.object
MessageReceiver

Constructor

MessageReceiver(session, source, target, on_message_received, name=None, receive_settle_mode=<ReceiverSettleMode.PeekLock: 1>, send_settle_mode=<SenderSettleMode.Unsettled: 0>, max_message_size=1048576, prefetch=300, properties=None, error_policy=None, debug=False, encoding='UTF-8', desired_capabilities=None)

Parameters

session
Session
Required

The underlying Session with which to receive.

source
Source
Required

The AMQP endpoint to receive from.

target
str or bytes
Required

The name of target (i.e. the client).

name
str or bytes
Required

A unique name for the receiver. If not specified a GUID will be used.

receive_settle_mode
ReceiverSettleMode
default value: None

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.

send_settle_mode
SenderSettleMode
default value: ReceiverSettleMode.PeekLock

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.

desired_capabilities
AMQPValue
default value: SenderSettleMode.Unsettled

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
default value: 1048576

The maximum allowed message size negotiated for the Link.

prefetch
int
default value: 300

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

properties
dict
default value: None

Metadata to be sent in the Link ATTACH frame.

error_policy
ErrorPolicy
default value: None

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

debug
bool
default value: False

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

encoding
str
default value: UTF-8

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

desired_capabilities
default value: None

Variables

receive_settle_mode
ReceiverSettleMode

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.

send_settle_mode
SenderSettleMode

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.

max_message_size
int

The maximum allowed message size negotiated for the Link.

Methods

close

Close the Receiver, leaving the link intact.

destroy

Close both the Receiver and the Link. Clean up any C objects.

get_state

Get the state of the MessageReceiver and its underlying Link.

on_state_changed

Callback called whenever the underlying Receiver undergoes a change of state. This function can be overridden.

open

Open the MessageReceiver in order to start processing messages.

reset_link_credit

Reset the link credit. This method would send flow control frame to the sender.

work

Update the link status.

close

Close the Receiver, leaving the link intact.

close()

destroy

Close both the Receiver and the Link. Clean up any C objects.

destroy()

get_state

Get the state of the MessageReceiver and its underlying Link.

get_state()

Return type

on_state_changed

Callback called whenever the underlying Receiver undergoes a change of state. This function can be overridden.

on_state_changed(previous_state, new_state)

Parameters

previous_state
MessageReceiverState
Required

The previous Receiver state.

new_state
MessageReceiverState
Required

The new Receiver state.

open

Open the MessageReceiver in order to start processing messages.

open()

Exceptions

uamqp.errors.AMQPConnectionError if the Receiver raisesan error on opening. This can happen if the source URI is invalidor the credentials are rejected.

Reset the link credit. This method would send flow control frame to the sender.

reset_link_credit(link_credit, **kwargs)

Parameters

link_credit
int
Required

The link credit amount that is requested.

work

Update the link status.

work()

Attributes

max_message_size

receive_settle_mode

send_settle_mode