Class MessageBody

  • All Implemented Interfaces:
    Serializable

    public class MessageBody
    extends Object
    implements Serializable
    This class encapsulates the body of a message. Body types map to AMQP message body types. It has getters and setters for multiple body types. Client should test for body type before calling corresponding get method. Get methods not corresponding to the type of the body return null.
    See Also:
    Serialized Form
    • Method Detail

      • fromValueData

        public static MessageBody fromValueData​(Object value)
        Creates message body of AMQPValue type.
        Parameters:
        value - AMQPValue content of the message. It must be of a type supported by AMQP.
        Returns:
        MessageBody instance wrapping around the value data.
      • fromSequenceData

        public static MessageBody fromSequenceData​(List<List<Object>> sequenceData)
        Creates a message body from a list of AMQPSequence sections.Each AMQPSequence section is in turn a list of objects. Please note that this version of the SDK supports only one AMQPSequence section in a message. It means only a list of exactly one sequence in it is accepted as message body.
        Parameters:
        sequenceData - a list of AMQPSequence sections. Each AMQPSequence section is in turn a list of objects. Every object in each list must of a type supported by AMQP.
        Returns:
        MessageBody instance wrapping around the sequence data.
      • fromBinaryData

        public static MessageBody fromBinaryData​(List<byte[]> binaryData)
        Creates a message body from a list of Data sections.Each Data section is a byte array. Please note that this version of the SDK supports only one Data section in a message. It means only a list of exactly one byte array in it is accepted as message body.
        Parameters:
        binaryData - a list of byte arrays.
        Returns:
        MessageBody instance wrapping around the binary data.
      • getValueData

        public Object getValueData()
        Returns the content of message body.
        Returns:
        value of message body only if the MessageBody is of Value type. Returns null otherwise.
      • getSequenceData

        public List<List<Object>> getSequenceData()
        Returns the content of message body.
        Returns:
        a list of AMQPSequence sections only if the MessageBody is of Sequence type. Returns null otherwise. Each AMQPSequence section is in turn a list of objects.
      • getBinaryData

        public List<byte[]> getBinaryData()
        Returns the content of message body.
        Returns:
        message body as list of byte arrays only if the MessageBody is of Binary type. Returns null otherwise.
      • getBodyType

        public MessageBodyType getBodyType()
        Return the type of content in this message body.
        Returns:
        type of message content