I am doing a HTTPRest post call to send the data to a third party, my data is in the order of 3 to 10 million and i can send only one record per request along with username and password for authentication as specified by third party
sample code that i am using is
public static void main(String[] args) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(
"http://localhost:8080/RESTfulExample/json/product/post");
StringEntity input = new StringEntity("{\"qty\":100,\"name\":\"iPad 4\"}");
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = httpClient.execute(postRequest);
if (response.getStatusLine().getStatusCode() != 201) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(
new InputStreamReader((response.getEntity().getContent())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
for each request it is taking around 6 sec and if i calculate for 10 million records it will take hours , can some one please suggest me are the any ways to improve the performance ??
thanks in advance Sunny