BatchMessage Class

A Batched AMQP message.

This batch message encodes multiple message bodies into a single message to increase through-put over the wire. It requires server-side support to unpackage the batched messages and so will not be universally supported.

Inheritance
BatchMessage

Constructor

BatchMessage(data=None, properties=None, application_properties=None, annotations=None, header=None, multi_messages=False, encoding='UTF-8')

Parameters

data
<xref:iterable>
default value: None

An iterable source of data, where each value will be considered the body of a single message in the batch.

properties
MessageProperties
default value: None

Properties to add to the message. If multiple messages are created these properties will be applied to each message.

application_properties
dict
default value: None

Service specific application properties. If multiple messages are created these properties will be applied to each message.

annotations
dict
default value: None

Service specific message annotations. If multiple messages are created these properties will be applied to each message. Keys in the dictionary must be types.AMQPSymbol or types.AMQPuLong.

header
MessageHeader
default value: None

The message header. This header will be applied to each message in the batch.

multi_messages
bool
default value: False

Whether to send the supplied data across multiple messages. If set to False, all the data will be sent in a single message, and an error raised if the message is too large. If set to True, the data will automatically be divided across multiple messages of an appropriate size. The default is False.

encoding
str
default value: UTF-8

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

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 ~uamqp.constants.MessageSendResult) and an error (of type Exception). The error parameter may be None if no error ocurred or the error information was undetermined.

batch_format
int

The is the specific message format to inform the service the the body should be interpreted as multiple messages. The value is 0x80013700.

max_message_length
int

The maximum data size in bytes to allow in a single message. By default this is 256kb. If sending a single batch message, an error will be raised if the supplied data exceeds this maximum. If sending multiple batch messages, this value will be used to divide the supplied data between messages.

Methods

gather

Return all the messages represented by this object. This will convert the batch data into individual Message objects, which may be one or more if multi_messages is set to True.

gather

Return all the messages represented by this object. This will convert the batch data into individual Message objects, which may be one or more if multi_messages is set to True.

gather()

Return type

Attributes

batch_format

batch_format = 2147563264

max_message_length

max_message_length = 1048576

size_offset

size_offset = 0