我正在做一個HTTPRest post調用以將數據發送給第三方, 我的數據大約在3至1000萬的數量級,我只能發送一個記錄,每個請求以及用戶名和密碼進行身份驗證由第三方指定Httprest性能改進
,我使用示例代碼
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();
}
}
的每一個請求它走大約6秒,如果我計算了10萬條記錄,這將需要幾個小時,可有一個人請建議我是任何提高性能的方法?
在此先感謝 陽光
親愛約傑什,比你 – Suresh
親愛約傑什,非常感謝你的反應,我已經包括jercy 1.4 .jar,但我正在編譯錯誤。它會用1.5嗎?我收到版本錯誤 – Suresh