Delen via


MessageBody Class

  • java.lang.Object
    • com.microsoft.azure.servicebus.MessageBody

Implements

public class MessageBody
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.

Method Summary

Modifier and Type Method and Description
static MessageBody fromBinaryData(List<byte[]> binaryData)

Creates a message body from a list of Data sections.Each Data section is a byte array.

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.

static MessageBody fromValueData(Object value)

Creates message body of AMQPValue type.

List<byte[]> getBinaryData()

Returns the content of message body.

MessageBodyType getBodyType()

Return the type of content in this message body.

List<List<Object>> getSequenceData()

Returns the content of message body.

Object getValueData()

Returns the content of message body.

Methods inherited from java.lang.Object

Method Details

fromBinaryData

public static MessageBody fromBinaryData(List 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.

fromSequenceData

public static MessageBody fromSequenceData(List> 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.

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.

getBinaryData

public List 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

getSequenceData

public List> 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.

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.

Applies to