0

I am using Cumulocity Java Agent to send sensor's data from Agent to server. Because of the volume of data is very huge, I want to send bulk of data in one Http post request. But after spending some hours looking at the source code of package com.cumulocity.sdk.client.measurement I think there is only the version of posting only one measurement at once. Am I right ? So, in my project, I am using HttpClient to send bulk of data (in format of a JSONArray) and it is working. But my client wants to know why I have to implement it myself, so I wonder whether the API has not been implemented yet or I am wrong.

Thanks a lot.

1 Answers1

0

It is correct that the com.cumulocity.sdk.client.measurement does not offer an implementation for the bulk API for measurements at the moment.

However you can use the generic class com.cumulocity.sdk.client.RestConnector which is the base class for all the API implementations. It has a method public <T extends ResourceRepresentationWithId> T post(String path, CumulocityMediaType mediaType, T representation) throws SDKException. You can either manuallly call that method or you add a new class for MeasurementBulk API which implements it.

So you don't have to do this call completly outside of the library.

TyrManuZ
  • 2,039
  • 1
  • 14
  • 23
  • Thank you for you respond. But now I have another question, I found that there are times my HTTP Request failed frequently. When I post an JSONArray of about 15.000 entities of measurement, the response is very slow and finally it failed. (Because I am using httpclient and will retry for 3 times when a request failed). Is there a limit of how many entities I can post in a http request ? – Vu Nhat Tan Mar 28 '17 at 05:34
  • There is direct limitation. Maybe the client times out wihle the 15k measurements are created – TyrManuZ Mar 29 '17 at 08:20