Message Class
An AMQP message.
When sending, if body type information is not provided, then depending on the nature of the data, different body encoding will be used. If the data is str or bytes, a single part DataBody will be sent. If the data is a list of str/bytes, a multipart DataBody will be sent. Any other type of list or any other type of data will be sent as a ValueBody. An empty payload will also be sent as a ValueBody. If body type information is provided, then the Message will use the given body type to encode the data or raise error if the data doesn't match the body type.
- Inheritance
-
builtins.objectMessage
Constructor
Message(body=None, properties=None, application_properties=None, annotations=None, header=None, msg_format=None, message=None, settler=None, delivery_no=None, encoding='UTF-8', body_type=None, footer=None, delivery_annotations=None)
Parameters
- body
- <xref:<xref:Any Python data type.>>
The data to send in the message.
- annotations
- dict
Service specific message annotations. Keys in the dictionary must be types.AMQPSymbol or types.AMQPuLong.
- message
- cMessage
Internal only. This is used to wrap an existing message that has been received from an AMQP service. If specified, all other parameters will be ignored.
- settler
- callable[MessageResponse]
Internal only. This is used when wrapping an existing message that has been received from an AMQP service. Should only be specified together with message and is to settle the message.
- delivery_no
Internal only. This is used when wrapping an existing message that has been received from an AMQP service. Should only be specified together with message and specifies the messages client delivery number.
- encoding
- str
The encoding to use for parameters supplied as strings. Default is 'UTF-8'
- body_type
- <xref:uamqp.MessageBodyType>
The AMQP body type used to specify the type of the body section of an amqp message. By default is None which means depending on the nature of the data, different body encoding will be used. If the data is str or bytes, a single part DataBody will be sent. If the data is a list of str/bytes, a multipart DataBody will be sent. Any other type of list or any other type of data will be sent as a ValueBody. An empty payload will also be sent as a ValueBody. Please check class ~uamqp.MessageBodyType for usage information of each body type.
Variables
- on_send_complete
- callable[MessageSendResult, Exception]
A custom callback to be run on completion of the send operation of this message. The callback must take two parameters, a result (of type MessageSendResult) and an error (of type Exception). The error parameter may be None if no error ocurred or the error information was undetermined.
Methods
| accept |
Send a response disposition to the service to indicate that a received message has been accepted. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. Returns True is message was accepted, or False if the message was already settled. |
| decode_from_bytes |
Decode an AMQP message from a bytearray. The returned message will not have a delivery context and therefore will be considered to be in an "already settled" state. |
| encode_message |
Encode message to AMQP wire-encoded bytearray. |
| gather |
Return all the messages represented by this object. This will always be a list of a single message. |
| get_data |
Get the body data of the message. The format may vary depending on the body type. |
| get_message |
Get the underlying C message from this object. |
| get_message_encoded_size |
Pre-emptively get the size of the message once it has been encoded to go over the wire so we can raise an error if the message will be rejected for being to large. This method is not available for messages that have been received. |
| modify |
Send a response disposition to the service to indicate that a received message has been modified. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. Returns True is message was modified, or False if the message was already settled. |
| reject |
Send a response disposition to the service to indicate that a received message has been rejected. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. A rejected message will increment the messages delivery count. Returns True is message was rejected, or False if the message was already settled. |
| release |
Send a response disposition to the service to indicate that a received message has been released. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. A released message will not incremenet the messages delivery count. Returns True is message was released, or False if the message was already settled. |
accept
Send a response disposition to the service to indicate that a received message has been accepted. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. Returns True is message was accepted, or False if the message was already settled.
accept()
Return type
Exceptions
decode_from_bytes
Decode an AMQP message from a bytearray. The returned message will not have a delivery context and therefore will be considered to be in an "already settled" state.
decode_from_bytes(data)
Parameters
- data
Exceptions
encode_message
Encode message to AMQP wire-encoded bytearray.
encode_message()
Return type
Exceptions
gather
Return all the messages represented by this object. This will always be a list of a single message.
gather()
Return type
Exceptions
get_data
Get the body data of the message. The format may vary depending on the body type.
get_data()
Return type
Exceptions
get_message
Get the underlying C message from this object.
get_message()
Return type
Exceptions
get_message_encoded_size
Pre-emptively get the size of the message once it has been encoded to go over the wire so we can raise an error if the message will be rejected for being to large.
This method is not available for messages that have been received.
get_message_encoded_size()
Return type
Exceptions
modify
Send a response disposition to the service to indicate that a received message has been modified. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. Returns True is message was modified, or False if the message was already settled.
modify(failed, deliverable, annotations=None)
Parameters
- failed
- bool
Whether this delivery of this message failed. This does not indicate whether subsequence deliveries of this message would also fail.
- deliverable
- bool
Whether this message will be deliverable to this client on subsequent deliveries - i.e. whether delivery is retryable.
Return type
Exceptions
reject
Send a response disposition to the service to indicate that a received message has been rejected. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. A rejected message will increment the messages delivery count. Returns True is message was rejected, or False if the message was already settled.
reject(condition=None, description=None, info=None)
Parameters
The AMQP rejection code. By default this is amqp:internal-error.
Return type
Exceptions
release
Send a response disposition to the service to indicate that a received message has been released. If the client is running in PeekLock mode, the service will wait on this disposition. Otherwise it will be ignored. A released message will not incremenet the messages delivery count. Returns True is message was released, or False if the message was already settled.
release()
Return type
Exceptions
Attributes
annotations
application_properties
delivery_annotations
footer
header
properties
settled
Whether the message transaction for this message has been completed. If this message is to be sent, the message will be settled=True once a disposition has been received from the service. If this message has been received, the message will be settled=True once a disposition has been sent to the service.
Return type
Feedback
Submit and view feedback for