通过


你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

HttpsBatchMessage Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.transport.https.HttpsBatchMessage

Implements

public final class HttpsBatchMessage
implements HttpsMessage

Builds a batched IoT Hub request body as a JSON array. The batched message has a maximum size of 256 kb.

Constructor Summary

Constructor Description
HttpsBatchMessage()

Constructor.

Method Summary

Modifier and Type Method and Description
void addMessage(HttpsSingleMessage msg)

Adds a message to the batch.

byte[] getBody()

Returns the current batch body as a UTF-8 encoded byte array.

java.lang.String getContentType()

Returns the message content-type as 'application/vnd.microsoft.iothub.json'.

MessageProperty[] getProperties()

Returns an empty list of properties for the batched message.

java.util.Map<java.lang.String,java.lang.String> getSystemProperties()

It is part of the HttpsMessage interface to get the collection of system message properties.

int numMessages()

Returns the number of messages currently in the batch.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

HttpsBatchMessage

public HttpsBatchMessage()

Constructor. Initializes the batch body as an empty JSON array.

Method Details

addMessage

public void addMessage(HttpsSingleMessage msg)

Adds a message to the batch.

Parameters:

msg - the message to be added.

Throws:

IotHubSizeExceededException - if adding the message causes the batched message to exceed 256 kb in size. The batched message will remain as if the message was never added.

getBody

public byte[] getBody()

Returns the current batch body as a UTF-8 encoded byte array.

Returns:

the current batch body as a UTF-8 encoded byte array.

getContentType

public String getContentType()

Returns the message content-type as 'application/vnd.microsoft.iothub.json'.

Returns:

the message content-type as 'application/vnd.microsoft.iothub.json'.

getProperties

public MessageProperty[] getProperties()

Returns an empty list of properties for the batched message.

Returns:

an empty list of properties for the batched message.

getSystemProperties

public Map<String,String> getSystemProperties()

It is part of the HttpsMessage interface to get the collection of system message properties. For batch, it just returns a empty Map.

Returns:

an empty Map.

numMessages

public int numMessages()

Returns the number of messages currently in the batch.

Returns:

the number of messages currently in the batch.

Applies to