From 86d26c8793c9598c0e3c35b79b01eedfa82e883d Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Sat, 11 Jan 2025 13:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E5=BA=95?= =?UTF-8?q?=E5=B1=82=E9=80=9A=E8=AE=AF=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=EF=BC=8C=E9=BB=98?= =?UTF-8?q?=E8=AE=A43S=EF=BC=9B=E5=8F=AF=E5=8F=82=E8=80=83=20xxl-job-admin?= =?UTF-8?q?=20=E5=92=8C=20samples=20=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=87=AA=E8=A1=8C=E9=85=8D=E7=BD=AE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 120 ++++++++++-------- .../admin/core/conf/XxlJobAdminConfig.java | 7 + .../admin/core/scheduler/XxlJobScheduler.java | 4 +- .../src/main/resources/application.properties | 20 +-- .../com/xxl/job/adminbiz/AdminBizTest.java | 7 +- .../xxl/job/executorbiz/ExecutorBizTest.java | 11 +- .../job/core/biz/client/AdminBizClient.java | 8 +- .../core/biz/client/ExecutorBizClient.java | 8 +- .../xxl/job/core/executor/XxlJobExecutor.java | 10 +- .../xxl/job/core/util/XxlJobRemotingUtil.java | 4 +- .../config/FrameLessXxlJobConfig.java | 3 +- .../resources/xxl-job-executor.properties | 7 +- .../executor/core/config/XxlJobConfig.java | 6 +- .../src/main/resources/application.properties | 5 +- 14 files changed, 132 insertions(+), 88 deletions(-) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 9711cf2c..86fc56c6 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -843,40 +843,45 @@ XXL-JOB是一个分布式任务调度平台,其核心设计目标是开发迅 #### 步骤一:调度中心配置: 调度中心配置文件地址: - /xxl-job/xxl-job-admin/src/main/resources/application.properties - +``` +/xxl-job/xxl-job-admin/src/main/resources/application.properties +``` 调度中心配置内容说明: - ### 调度中心JDBC链接:链接地址请保持和 2.1章节 所创建的调度数据库的地址一致 - spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai - spring.datasource.username=root - spring.datasource.password=root_pwd - spring.datasource.driver-class-name=com.mysql.jdbc.Driver - - ### 报警邮箱 - spring.mail.host=smtp.qq.com - spring.mail.port=25 - spring.mail.username=xxx@qq.com - spring.mail.password=xxx - spring.mail.properties.mail.smtp.auth=true - spring.mail.properties.mail.smtp.starttls.enable=true - spring.mail.properties.mail.smtp.starttls.required=true - spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory - - ### 调度中心通讯TOKEN [选填]:非空时启用; - xxl.job.accessToken= - - ### 调度中心国际化配置 [必填]: 默认为 "zh_CN"/中文简体, 可选范围为 "zh_CN"/中文简体, "zh_TC"/中文繁体 and "en"/英文; - xxl.job.i18n=zh_CN - - ## 调度线程池最大线程配置【必填】 - xxl.job.triggerpool.fast.max=200 - xxl.job.triggerpool.slow.max=100 - - ### 调度中心日志表数据保存天数 [必填]:过期日志自动清理;限制大于等于7时生效,否则, 如-1,关闭自动清理功能; - xxl.job.logretentiondays=30 - +``` +### 调度中心JDBC链接:链接地址请保持和 2.1章节 所创建的调度数据库的地址一致 +spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai +spring.datasource.username=root +spring.datasource.password=root_pwd +spring.datasource.driver-class-name=com.mysql.jdbc.Driver + +### 报警邮箱 +spring.mail.host=smtp.qq.com +spring.mail.port=25 +spring.mail.username=xxx@qq.com +spring.mail.password=xxx +spring.mail.properties.mail.smtp.auth=true +spring.mail.properties.mail.smtp.starttls.enable=true +spring.mail.properties.mail.smtp.starttls.required=true +spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory + +### 调度中心通讯TOKEN [选填]:非空时启用; +xxl.job.accessToken= + +### 调度中心通讯超时时间[选填],单位秒;默认3s; +xxl.job.timeout=3 + +### 调度中心国际化配置 [必填]: 默认为 "zh_CN"/中文简体, 可选范围为 "zh_CN"/中文简体, "zh_TC"/中文繁体 and "en"/英文; +xxl.job.i18n=zh_CN + +## 调度线程池最大线程配置【必填】 +xxl.job.triggerpool.fast.max=200 +xxl.job.triggerpool.slow.max=100 + +### 调度中心日志表数据保存天数 [必填]:过期日志自动清理;限制大于等于7时生效,否则, 如-1,关闭自动清理功能; +xxl.job.logretentiondays=30 +``` #### 步骤二:部署项目: @@ -931,29 +936,35 @@ docker run -e PARAMS="--spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_jo #### 步骤二:执行器配置 执行器配置,配置文件地址: - /xxl-job/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties +``` +/xxl-job/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties +``` 执行器配置,配置内容说明: - ### 调度中心部署根地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册; - xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin - - ### 执行器通讯TOKEN [选填]:非空时启用; - xxl.job.accessToken= - - ### 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册 - xxl.job.executor.appname=xxl-job-executor-sample - ### 执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。 - xxl.job.executor.address= - ### 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; - xxl.job.executor.ip= - ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口; - xxl.job.executor.port=9999 - ### 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径; - xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler - ### 执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; - xxl.job.executor.logretentiondays=30 - +``` +### 调度中心部署根地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册; +xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin + +### 调度中心通讯TOKEN [选填]:非空时启用; +xxl.job.admin.accessToken=default_token + +### 调度中心通讯超时时间[选填],单位秒;默认3s; +xxl.job.admin.timeout=3 + +### 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册 +xxl.job.executor.appname=xxl-job-executor-sample +### 执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。 +xxl.job.executor.address= +### 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; +xxl.job.executor.ip= +### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口; +xxl.job.executor.port=9999 +### 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径; +xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler +### 执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; +xxl.job.executor.logretentiondays=30 +``` #### 步骤三:执行器组件配置 @@ -2402,14 +2413,15 @@ public void execute() { ### 7.36 版本 v2.5.0 Release Notes[规划中] - 1、【优化】框架基础守护线程异常处理逻辑优化,避免极端情况下因Error导致调度终止问题; -- 2、【优化】部分系统日志优化,提升可读性; +- 2、【优化】底层通讯超时时间支持自定义,默认3S;可参考 xxl-job-admin 和 samples 示例代码自行配置; - 3、【重构】调度线程任务信息更新逻辑优化,避免极端情况下已关闭任务被启动问题; -- 5、【重构】执行器注册逻辑重构,降低多调度中心地址时并发注册问题;注册表“xxl_job_registry”新增唯一索引,避免冗余注册信息存储; +- 4、【重构】执行器注册逻辑重构,降低多调度中心地址时并发注册问题;注册表“xxl_job_registry”新增唯一索引,避免冗余注册信息存储; +- 5、【优化】部分系统日志优化,提升可读性; - 6、【优化】合并PR-3616,代码结构注释优化; - 7、【优化】合并PR-3619,避免调度过程中任务停止边界情况处理逻辑; - 8、【优化】合并PR-3605,避免子任务是任务本身导致死循环; - 9、【修复】合并PR-3585,修复全局密码长度不一致问题; -- 10、【优化】合并PR-3518,将列别名反引号包裹,提升跨数据迁移兼容性; +- 10、【优化】合并PR-3518,SQL列别名反引号包裹,提升跨数据迁移兼容性; - 11、【优化】合并PR-3518、PR-3400,日志表索引优化,提升大日志量情况下日志查询及清理速度; - 12、[规划中]登陆态Token声称逻辑优化,混淆登陆时间属性,降低token泄漏风险; - 13、[规划中]升级springboot3.x,解决2.x老版本漏洞类问题。注意,springboot3.x依赖jdk17; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java index 380b8a59..b48f469b 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java @@ -55,6 +55,9 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean { @Value("${xxl.job.accessToken}") private String accessToken; + @Value("${xxl.job.timeout}") + private int timeout; + @Value("${spring.mail.from}") private String emailFrom; @@ -98,6 +101,10 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean { return accessToken; } + public int getTimeout() { + return timeout; + } + public String getEmailFrom() { return emailFrom; } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java index bb2cda8b..8a0f4a06 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java @@ -92,7 +92,9 @@ public class XxlJobScheduler { } // set-cache - executorBiz = new ExecutorBizClient(address, XxlJobAdminConfig.getAdminConfig().getAccessToken()); + executorBiz = new ExecutorBizClient(address, + XxlJobAdminConfig.getAdminConfig().getAccessToken(), + XxlJobAdminConfig.getAdminConfig().getTimeout()); executorBizRepository.put(address, executorBiz); return executorBiz; diff --git a/xxl-job-admin/src/main/resources/application.properties b/xxl-job-admin/src/main/resources/application.properties index d438057d..5eb0f736 100644 --- a/xxl-job-admin/src/main/resources/application.properties +++ b/xxl-job-admin/src/main/resources/application.properties @@ -3,13 +3,13 @@ server.port=8080 server.servlet.context-path=/xxl-job-admin ### actuator -management.server.servlet.context-path=/actuator +management.server.base-path=/actuator management.health.mail.enabled=false ### resources spring.mvc.servlet.load-on-startup=0 spring.mvc.static-path-pattern=/static/** -spring.resources.static-locations=classpath:/static/ +spring.web.resources.static-locations=classpath:/static/ ### freemarker spring.freemarker.templateLoaderPath=classpath:/templates/ @@ -21,13 +21,6 @@ spring.freemarker.settings.new_builtin_class_resolver=safer ### mybatis mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml -#mybatis.type-aliases-package=com.xxl.job.admin.core.model - -### xxl-job, datasource -spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai -spring.datasource.username=root -spring.datasource.password=root_pwd -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver ### datasource-pool spring.datasource.type=com.zaxxer.hikari.HikariDataSource @@ -41,6 +34,12 @@ spring.datasource.hikari.connection-timeout=10000 spring.datasource.hikari.connection-test-query=SELECT 1 spring.datasource.hikari.validation-timeout=1000 +### xxl-job, datasource +spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai +spring.datasource.username=root +spring.datasource.password=root_pwd +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + ### xxl-job, email spring.mail.host=smtp.qq.com spring.mail.port=25 @@ -55,6 +54,9 @@ spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFact ### xxl-job, access token xxl.job.accessToken=default_token +### xxl-job, access token +xxl.job.timeout=3 + ### xxl-job, i18n (default is zh_CN, and you can choose "zh_CN", "zh_TC" and "en") xxl.job.i18n=zh_CN diff --git a/xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java b/xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java index 6fb89e7f..29d37c9c 100644 --- a/xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java +++ b/xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java @@ -24,11 +24,12 @@ public class AdminBizTest { // admin-client private static String addressUrl = "http://127.0.0.1:8080/xxl-job-admin/"; private static String accessToken = null; + private static int timeoutSecond = 3; @Test public void callback() throws Exception { - AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken); + AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken, timeoutSecond); HandleCallbackParam param = new HandleCallbackParam(); param.setLogId(1); @@ -48,7 +49,7 @@ public class AdminBizTest { */ @Test public void registry() throws Exception { - AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken); + AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken, timeoutSecond); RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999"); ReturnT returnT = adminBiz.registry(registryParam); @@ -63,7 +64,7 @@ public class AdminBizTest { */ @Test public void registryRemove() throws Exception { - AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken); + AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken, timeoutSecond); RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999"); ReturnT returnT = adminBiz.registryRemove(registryParam); diff --git a/xxl-job-admin/src/test/java/com/xxl/job/executorbiz/ExecutorBizTest.java b/xxl-job-admin/src/test/java/com/xxl/job/executorbiz/ExecutorBizTest.java index 4facb89f..46e710e5 100644 --- a/xxl-job-admin/src/test/java/com/xxl/job/executorbiz/ExecutorBizTest.java +++ b/xxl-job-admin/src/test/java/com/xxl/job/executorbiz/ExecutorBizTest.java @@ -18,10 +18,11 @@ public class ExecutorBizTest { // admin-client private static String addressUrl = "http://127.0.0.1:9999/"; private static String accessToken = null; + private static int timeout = 3; @Test public void beat() throws Exception { - ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken); + ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken, timeout); // Act final ReturnT retval = executorBiz.beat(); @@ -34,7 +35,7 @@ public class ExecutorBizTest { @Test public void idleBeat(){ - ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken); + ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken, timeout); final int jobId = 0; @@ -50,7 +51,7 @@ public class ExecutorBizTest { @Test public void run(){ - ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken); + ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken, timeout); // trigger data final TriggerParam triggerParam = new TriggerParam(); @@ -73,7 +74,7 @@ public class ExecutorBizTest { @Test public void kill(){ - ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken); + ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken, timeout); final int jobId = 0; @@ -89,7 +90,7 @@ public class ExecutorBizTest { @Test public void log(){ - ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken); + ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken, timeout); final long logDateTim = 0L; final long logId = 0; diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/AdminBizClient.java b/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/AdminBizClient.java index 95fa5608..b5c26b46 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/AdminBizClient.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/AdminBizClient.java @@ -17,19 +17,23 @@ public class AdminBizClient implements AdminBiz { public AdminBizClient() { } - public AdminBizClient(String addressUrl, String accessToken) { + public AdminBizClient(String addressUrl, String accessToken, int timeout) { this.addressUrl = addressUrl; this.accessToken = accessToken; + this.timeout = timeout; // valid if (!this.addressUrl.endsWith("/")) { this.addressUrl = this.addressUrl + "/"; } + if (!(this.timeout >=1 && this.timeout <= 10)) { + this.timeout = 3; + } } private String addressUrl ; private String accessToken; - private int timeout = 3; + private int timeout; @Override diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/ExecutorBizClient.java b/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/ExecutorBizClient.java index 9f594309..8912f68a 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/ExecutorBizClient.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/biz/client/ExecutorBizClient.java @@ -13,19 +13,23 @@ public class ExecutorBizClient implements ExecutorBiz { public ExecutorBizClient() { } - public ExecutorBizClient(String addressUrl, String accessToken) { + public ExecutorBizClient(String addressUrl, String accessToken, int timeout) { this.addressUrl = addressUrl; this.accessToken = accessToken; + this.timeout = timeout; // valid if (!this.addressUrl.endsWith("/")) { this.addressUrl = this.addressUrl + "/"; } + if (!(this.timeout >=1 && this.timeout <= 10)) { + this.timeout = 3; + } } private String addressUrl ; private String accessToken; - private int timeout = 3; + private int timeout; @Override diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java b/xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java index 4719b7b7..e0d36192 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java @@ -31,6 +31,7 @@ public class XxlJobExecutor { // ---------------------- param ---------------------- private String adminAddresses; private String accessToken; + private int timeout; private String appname; private String address; private String ip; @@ -44,6 +45,9 @@ public class XxlJobExecutor { public void setAccessToken(String accessToken) { this.accessToken = accessToken; } + public void setTimeout(int timeout) { + this.timeout = timeout; + } public void setAppname(String appname) { this.appname = appname; } @@ -71,7 +75,7 @@ public class XxlJobExecutor { XxlJobFileAppender.initLogPath(logPath); // init invoker, admin-client - initAdminBizList(adminAddresses, accessToken); + initAdminBizList(adminAddresses, accessToken, timeout); // init JobLogFileCleanThread @@ -117,12 +121,12 @@ public class XxlJobExecutor { // ---------------------- admin-client (rpc invoker) ---------------------- private static List adminBizList; - private void initAdminBizList(String adminAddresses, String accessToken) throws Exception { + private void initAdminBizList(String adminAddresses, String accessToken, int timeout) throws Exception { if (adminAddresses!=null && adminAddresses.trim().length()>0) { for (String address: adminAddresses.trim().split(",")) { if (address!=null && address.trim().length()>0) { - AdminBiz adminBiz = new AdminBizClient(address.trim(), accessToken); + AdminBiz adminBiz = new AdminBizClient(address.trim(), accessToken, timeout); if (adminBizList == null) { adminBizList = new ArrayList(); diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java b/xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java index d22a73e7..63fb3ccc 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java @@ -60,7 +60,7 @@ public class XxlJobRemotingUtil { * * @param url * @param accessToken - * @param timeout + * @param timeout by second * @param requestObj * @param returnTargClassOfT * @return @@ -86,7 +86,7 @@ public class XxlJobRemotingUtil { connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(timeout * 1000); - connection.setConnectTimeout(3 * 1000); + connection.setConnectTimeout(timeout * 1000); connection.setRequestProperty("connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8"); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/config/FrameLessXxlJobConfig.java b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/config/FrameLessXxlJobConfig.java index 1d882dc5..36349496 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/config/FrameLessXxlJobConfig.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xxl/job/executor/sample/frameless/config/FrameLessXxlJobConfig.java @@ -36,7 +36,8 @@ public class FrameLessXxlJobConfig { // init executor xxlJobExecutor = new XxlJobSimpleExecutor(); xxlJobExecutor.setAdminAddresses(xxlJobProp.getProperty("xxl.job.admin.addresses")); - xxlJobExecutor.setAccessToken(xxlJobProp.getProperty("xxl.job.accessToken")); + xxlJobExecutor.setAccessToken(xxlJobProp.getProperty("xxl.job.admin.accessToken")); + xxlJobExecutor.setTimeout(Integer.valueOf(xxlJobProp.getProperty("xxl.job.admin.timeout"))); xxlJobExecutor.setAppname(xxlJobProp.getProperty("xxl.job.executor.appname")); xxlJobExecutor.setAddress(xxlJobProp.getProperty("xxl.job.executor.address")); xxlJobExecutor.setIp(xxlJobProp.getProperty("xxl.job.executor.ip")); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/resources/xxl-job-executor.properties b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/resources/xxl-job-executor.properties index 9b1ab8a7..5c66d2c8 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/resources/xxl-job-executor.properties +++ b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/resources/xxl-job-executor.properties @@ -1,8 +1,9 @@ ### xxl-job admin address list, such as "http://address" or "http://address01,http://address02" xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin - -### xxl-job, access token -xxl.job.accessToken=default_token +### xxl-job access-token +xxl.job.admin.accessToken=default_token +### xxl-job timeout by second, default 3s +xxl.job.admin.timeout=3 ### xxl-job executor appname xxl.job.executor.appname=xxl-job-executor-sample diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java index bfd80e22..b60c3dee 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java @@ -19,9 +19,12 @@ public class XxlJobConfig { @Value("${xxl.job.admin.addresses}") private String adminAddresses; - @Value("${xxl.job.accessToken}") + @Value("${xxl.job.admin.accessToken}") private String accessToken; + @Value("${xxl.job.admin.timeout}") + private int timeout; + @Value("${xxl.job.executor.appname}") private String appname; @@ -51,6 +54,7 @@ public class XxlJobConfig { xxlJobSpringExecutor.setIp(ip); xxlJobSpringExecutor.setPort(port); xxlJobSpringExecutor.setAccessToken(accessToken); + xxlJobSpringExecutor.setTimeout(timeout); xxlJobSpringExecutor.setLogPath(logPath); xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties index 14c796e8..a97ab628 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties +++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties @@ -9,9 +9,10 @@ logging.config=classpath:logback.xml ### xxl-job admin address list, such as "http://address" or "http://address01,http://address02" xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin - ### xxl-job, access token -xxl.job.accessToken=default_token +xxl.job.admin.accessToken=default_token +### xxl-job timeout by second, default 3s +xxl.job.admin.timeout=3 ### xxl-job executor appname xxl.job.executor.appname=xxl-job-executor-sample