Dela via


Message Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.messaging.Message

public class Message

IotHub specific message container

Constructor Summary

Constructor Description
Message()

Basic constructor

Message(byte[] byteArray)

byteArray: a byte array containing the body of the message

Message(ByteArrayInputStream stream)

stream: a stream containing the body of the message

Message(String string)

Method Summary

Modifier and Type Method and Description
void clearCustomProperties()
ByteArrayOutputStream getBodyStream()

The stream content of the body.

byte [] getBytes()

The byte content of the body.

Map<String, String> getProperties()
final void setDeliveryAcknowledgement(DeliveryAcknowledgement deliveryAcknowledgement)
void setProperties(Map<String, String> properties)
void setTo(String deviceId)

Constructor Details

Message

public Message()

Basic constructor

Message

public Message(byte[] byteArray)

byteArray: a byte array containing the body of the message

Parameters:

byteArray - The byte array containing the message body

Message

public Message(ByteArrayInputStream stream)

stream: a stream containing the body of the message

Parameters:

stream - The stream containing the message body

Message

public Message(String string)

Parameters:

string - - a string containing the body of the message. Important: If a string is passed, the HttpBatch.SerializeAsString is set to true, and the internal byte representation is serialized as UTF-8, with HttpBatch.Encoding set to UTF-8.

Method Details

clearCustomProperties

public void clearCustomProperties()

getBodyStream

public ByteArrayOutputStream getBodyStream()

The stream content of the body.

Returns:

The ByteArrayOutputStream object containing the message body

getBytes

public byte [] getBytes()

The byte content of the body.

Returns:

The byte array of the message body

getProperties

public Map getProperties()

setDeliveryAcknowledgement

public final void setDeliveryAcknowledgement(DeliveryAcknowledgement deliveryAcknowledgement)

Parameters:

deliveryAcknowledgement - the delivery acknowledgement to set

setProperties

public void setProperties(Map properties)

Parameters:

properties

setTo

public void setTo(String deviceId)

Parameters:

deviceId

Applies to