def encode_message(self):
        """Encode message to AMQP wire-encoded bytearray.

        :rtype: bytearray
        """
        if not self._message:
            raise ValueError("No message data to encode.")
        cloned_data = self._message.clone()
        self._populate_message_attributes(cloned_data)
        encoded_data = []
        c_uamqp.get_encoded_message_size(cloned_data, encoded_data)
        return b"".join(encoded_data)
Example #2
0
 def get_message_encoded_size(self):
     """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.
     :returns: int
     """
     # TODO: This no longer calculates the metadata accurately.
     return c_uamqp.get_encoded_message_size(self._message)
    def get_message_encoded_size(self):
        """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.

        :rtype: int
        """
        if not self._message:
            raise ValueError("No message data to encode.")
        cloned_data = self._message.clone()
        self._populate_message_attributes(cloned_data)
        encoded_data = []
        return c_uamqp.get_encoded_message_size(cloned_data, encoded_data)