This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 4.5.
Message Objects - kombu.message
¶
Message class.
-
class
kombu.message.
Message
(body=None, delivery_tag=None, content_type=None, content_encoding=None, delivery_info=None, properties=None, headers=None, postencode=None, accept=None, channel=None, **kwargs)[source]¶ Base class for received messages.
- Keyword Arguments
channel (ChannelT) – If message was received, this should be the channel that the message was received on.
body (str) – Message body.
delivery_mode (bool) – Set custom delivery mode. Defaults to
delivery_mode
.priority (int) – Message priority, 0 to broker configured max priority, where higher is better.
content_type (str) – The messages content_type. If content_type is set, no serialization occurs as it is assumed this is either a binary object, or you’ve done your own serialization. Leave blank if using built-in serialization as our library properly sets content_type.
content_encoding (str) – The character set in which this object is encoded. Use “binary” if sending in raw binary objects. Leave blank if using built-in serialization as our library properly sets content_encoding.
properties (Dict) – Message properties.
headers (Dict) – Message headers.
-
exception
MessageStateError
¶ The message has already been acknowledged.
-
accept
¶
-
ack
(multiple=False)[source]¶ Acknowledge this message as being processed.
This will remove the message from the queue.
- Raises
MessageStateError – If the message has already been acknowledged/requeued/rejected.
-
property
acknowledged
¶ Set to true if the message has been acknowledged.
-
body
¶
-
channel
¶
-
content_encoding
¶
-
content_type
¶
-
decode
()[source]¶ Deserialize the message body.
Returning the original python structure sent by the publisher.
Note
The return value is memoized, use _decode to force re-evaluation.
-
delivery_info
¶
-
delivery_tag
¶
-
errors
= None¶
-
headers
¶
-
property
payload
¶ The decoded message body.
-
properties
¶
-
reject
(requeue=False)[source]¶ Reject this message.
The message will be discarded by the server.
- Raises
MessageStateError – If the message has already been acknowledged/requeued/rejected.
-
requeue
()[source]¶ Reject this message and put it back on the queue.
Warning
You must not use this method as a means of selecting messages to process.
- Raises
MessageStateError – If the message has already been acknowledged/requeued/rejected.