public final class HttpsBatchMessage extends Object implements HttpsMessage
| Modifier and Type | Field and Description |
|---|---|
static Charset |
BATCH_CHARSET
The charset used to encode IoT Hub messages.
|
protected String |
batchBody
The current batched message body.
|
static String |
HTTPS_BATCH_CONTENT_TYPE
The value for the "content-type" header field in a batched HTTPS
request.
|
protected int |
numMsgs
The current number of messages in the batch.
|
static int |
SERVICEBOUND_MESSAGE_MAX_SIZE_BYTES |
HTTPS_APP_PROPERTY_PREFIX| Constructor and Description |
|---|
HttpsBatchMessage()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static String |
addJsonObjToArray(String jsonObj,
String jsonArray)
Adds a JSON object to a JSON array.
|
void |
addMessage(HttpsSingleMessage msg)
Adds a message to the batch.
|
byte[] |
getBody()
Returns the current batch body as a UTF-8 encoded byte array.
|
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.
|
protected static String |
msgToJson(HttpsSingleMessage msg)
Converts a service-bound message to a JSON object with the correct
format.
|
int |
numMessages()
Returns the number of messages currently in the batch.
|
public static final int SERVICEBOUND_MESSAGE_MAX_SIZE_BYTES
public static String HTTPS_BATCH_CONTENT_TYPE
public static Charset BATCH_CHARSET
protected String batchBody
protected int numMsgs
public HttpsBatchMessage()
public void addMessage(HttpsSingleMessage msg) throws SizeLimitExceededException
msg - the message to be added.SizeLimitExceededException - 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.public byte[] getBody()
getBody in interface HttpsMessagepublic String getContentType()
getContentType in interface HttpsMessagepublic MessageProperty[] getProperties()
getProperties in interface HttpsMessagepublic int numMessages()
protected static String msgToJson(HttpsSingleMessage msg)
msg - the message to be converted to a corresponding JSON object.protected static String addJsonObjToArray(String jsonObj, String jsonArray)
jsonObj - the object to be added to the JSON array.jsonArray - the JSON array.Copyright © 2017. All rights reserved.