question

PalnatiVenkataS-5334 avatar image
0 Votes"
PalnatiVenkataS-5334 asked ·

Azure IoT Java SDK: How to send batch device to cloud messages

Currently i am able to send one telemetry message at a time from device to azure IoT but i didn't find any option to send batch of messages in java SDK. can anyone help me here how can we send batch messages using java SDK.

azure-iot-hubazure-iot-sdk
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AshokPeddakotla-MSFT avatar image
0 Votes"
AshokPeddakotla-MSFT answered ·

@PalnatiVenkataS-5334 Welcome to Q&A forum!


You can use HttpsBatchMessage class which builds a batched IoT Hub request body as a JSON array and sent to IoT Hub. The batched message has a maximum size of 256 kb.


As mentioned, Device-to-cloud messages can be at most 256 KB, and can be grouped in batches to optimize sends. Batches can be at most 256 KB.


IoT Hub only supports batch send over AMQP and HTTPS only at the moment. The SDK supports batch send over HTTP. * Batch send over AMQP and AMQP-WS, and add system properties on D2C messages are in progress.


See Microsoft Azure IoT SDKs for Java to understand more about Azure IoT SDKs for Java.



· 5 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AshokPeddakotla-MSFT


Thanks for you answer.


this class HttpsBatchMessage has a method to build request body as JSON array but i didn't see a method to send it over to
IoT hub.


For sending single telemetry message i used DeviceClient class to open connection to IoT hub and used sendEventAsync() method to send a message. It will be very helpful if you tell me which class or method should i use to send this batch request which has a type of HttpsBatchMessage.


0 Votes 0 ·

@AshokPeddakotla-MSFT


Just following up here to know if i miss anything here on the Java sdk to send batch data as JSON array.


i did some research to find any class to accept HttpsBatchMessage as request in Java SDK, but i didn't find anything related to it. If you provide me any link or example which is related to sending batch events using Java will be very helpful.



0 Votes 0 ·

@PalnatiVenkataS-5334 I am enquiring at the moment and provide you the suggestions as earliest. Appreciate your time and patience.


0 Votes 0 ·

@PalnatiVenkataS-5334 Apologies for the delay. Our Engineering team is tracking this issue raised here:

https://github.com/Azure/azure-iot-sdk-java/issues/863

We will be updating the status once we have any progress/updates on the Git issue.

0 Votes 0 ·

@PalnatiVenkataS-5334 Quoting response from the Git issue.

Azad has checked in the feature for sending a batch message over HTTP, and we have released that feature in device client version 1.25.0. Since this feature has been released for HTTP, I'm going to close this issue

0 Votes 0 ·