|
|
@ -28,25 +28,36 @@ public class HttpJobHandler extends IJobHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// httpclient
|
|
|
|
// httpclient
|
|
|
|
HttpClient httpClient = new HttpClient();
|
|
|
|
HttpClient httpClient = null;
|
|
|
|
httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
|
|
|
|
try {
|
|
|
|
httpClient.start(); // Start HttpClient
|
|
|
|
httpClient = new HttpClient();
|
|
|
|
|
|
|
|
httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
|
|
|
|
// request
|
|
|
|
httpClient.start(); // Start HttpClient
|
|
|
|
Request request = httpClient.newRequest(param);
|
|
|
|
|
|
|
|
request.method(HttpMethod.GET);
|
|
|
|
// request
|
|
|
|
request.timeout(5000, TimeUnit.MILLISECONDS);
|
|
|
|
Request request = httpClient.newRequest(param);
|
|
|
|
|
|
|
|
request.method(HttpMethod.GET);
|
|
|
|
// invoke
|
|
|
|
request.timeout(5000, TimeUnit.MILLISECONDS);
|
|
|
|
ContentResponse response = request.send();
|
|
|
|
|
|
|
|
if (response.getStatus() != HttpStatus.OK_200) {
|
|
|
|
// invoke
|
|
|
|
XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
|
|
|
|
ContentResponse response = request.send();
|
|
|
|
|
|
|
|
if (response.getStatus() != HttpStatus.OK_200) {
|
|
|
|
|
|
|
|
XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
|
|
|
|
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String responseMsg = response.getContentAsString();
|
|
|
|
|
|
|
|
XxlJobLogger.log(responseMsg);
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
XxlJobLogger.log(e);
|
|
|
|
return FAIL;
|
|
|
|
return FAIL;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
if (httpClient != null) {
|
|
|
|
|
|
|
|
httpClient.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String responseMsg = response.getContentAsString();
|
|
|
|
|
|
|
|
XxlJobLogger.log(responseMsg);
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|