diff --git a/xxl-job-admin/Dockerfile b/xxl-job-admin/Dockerfile index 336db09e..be431040 100644 --- a/xxl-job-admin/Dockerfile +++ b/xxl-job-admin/Dockerfile @@ -3,6 +3,6 @@ MAINTAINER xuxueli ENV PARAMS="" -ADD target/xxl-conf-admin-*.jar /app.jar +ADD target/xxl-job-admin-*.jar /app.jar ENTRYPOINT ["sh","-c","java -jar /app.jar $PARAMS"] \ No newline at end of file diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java index 88b36cf4..a4fa6b97 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java @@ -28,25 +28,36 @@ public class HttpJobHandler extends IJobHandler { } // httpclient - HttpClient httpClient = new HttpClient(); - httpClient.setFollowRedirects(false); // Configure HttpClient, for example: - httpClient.start(); // Start HttpClient - - // request - Request request = httpClient.newRequest(param); - request.method(HttpMethod.GET); - request.timeout(5000, TimeUnit.MILLISECONDS); - - // invoke - ContentResponse response = request.send(); - if (response.getStatus() != HttpStatus.OK_200) { - XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus()); + HttpClient httpClient = null; + try { + httpClient = new HttpClient(); + httpClient.setFollowRedirects(false); // Configure HttpClient, for example: + httpClient.start(); // Start HttpClient + + // request + Request request = httpClient.newRequest(param); + request.method(HttpMethod.GET); + request.timeout(5000, TimeUnit.MILLISECONDS); + + // invoke + 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; + } finally { + if (httpClient != null) { + httpClient.stop(); + } } - String responseMsg = response.getContentAsString(); - XxlJobLogger.log(responseMsg); - return SUCCESS; } } diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java index 45d2268e..615bbd88 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java @@ -32,25 +32,36 @@ public class HttpJobHandler extends IJobHandler { } // httpclient - HttpClient httpClient = new HttpClient(); - httpClient.setFollowRedirects(false); // Configure HttpClient, for example: - httpClient.start(); // Start HttpClient - - // request - Request request = httpClient.newRequest(param); - request.method(HttpMethod.GET); - request.timeout(5000, TimeUnit.MILLISECONDS); - - // invoke - ContentResponse response = request.send(); - if (response.getStatus() != HttpStatus.OK_200) { - XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus()); + HttpClient httpClient = null; + try { + httpClient = new HttpClient(); + httpClient.setFollowRedirects(false); // Configure HttpClient, for example: + httpClient.start(); // Start HttpClient + + // request + Request request = httpClient.newRequest(param); + request.method(HttpMethod.GET); + request.timeout(5000, TimeUnit.MILLISECONDS); + + // invoke + 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; + } finally { + if (httpClient != null) { + httpClient.stop(); + } } - String responseMsg = response.getContentAsString(); - XxlJobLogger.log(responseMsg); - return SUCCESS; } } diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java index ea68d749..61dbab1c 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java @@ -32,25 +32,36 @@ public class HttpJobHandler extends IJobHandler { } // httpclient - HttpClient httpClient = new HttpClient(); - httpClient.setFollowRedirects(false); // Configure HttpClient, for example: - httpClient.start(); // Start HttpClient - - // request - Request request = httpClient.newRequest(param); - request.method(HttpMethod.GET); - request.timeout(5000, TimeUnit.MILLISECONDS); - - // invoke - ContentResponse response = request.send(); - if (response.getStatus() != HttpStatus.OK_200) { - XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus()); + HttpClient httpClient = null; + try { + httpClient = new HttpClient(); + httpClient.setFollowRedirects(false); // Configure HttpClient, for example: + httpClient.start(); // Start HttpClient + + // request + Request request = httpClient.newRequest(param); + request.method(HttpMethod.GET); + request.timeout(5000, TimeUnit.MILLISECONDS); + + // invoke + 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; + } finally { + if (httpClient != null) { + httpClient.stop(); + } } - String responseMsg = response.getContentAsString(); - XxlJobLogger.log(responseMsg); - return SUCCESS; } } diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java index ea68d749..61dbab1c 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java @@ -32,25 +32,36 @@ public class HttpJobHandler extends IJobHandler { } // httpclient - HttpClient httpClient = new HttpClient(); - httpClient.setFollowRedirects(false); // Configure HttpClient, for example: - httpClient.start(); // Start HttpClient - - // request - Request request = httpClient.newRequest(param); - request.method(HttpMethod.GET); - request.timeout(5000, TimeUnit.MILLISECONDS); - - // invoke - ContentResponse response = request.send(); - if (response.getStatus() != HttpStatus.OK_200) { - XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus()); + HttpClient httpClient = null; + try { + httpClient = new HttpClient(); + httpClient.setFollowRedirects(false); // Configure HttpClient, for example: + httpClient.start(); // Start HttpClient + + // request + Request request = httpClient.newRequest(param); + request.method(HttpMethod.GET); + request.timeout(5000, TimeUnit.MILLISECONDS); + + // invoke + 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; + } finally { + if (httpClient != null) { + httpClient.stop(); + } } - String responseMsg = response.getContentAsString(); - XxlJobLogger.log(responseMsg); - return SUCCESS; } } diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/logback.xml b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/logback.xml index bbea067c..d5a0d2ca 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/logback.xml +++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/logback.xml @@ -5,9 +5,6 @@ - %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n @@ -29,9 +26,4 @@ - - \ No newline at end of file