commit d4df7efb9b4bfd4ced25c2afba0848b40294b4df Author: LQS <2506203757@qq.com> Date: Wed Jul 24 20:49:05 2024 +0800 初始化 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e4e89fb --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..e6fa7ca --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9e1cc11 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4af9214 --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + com.muyu + cloud-common + 3.6.3 + + + cloud-common-xxl + + XllJob定时任务 + + + 17 + 17 + UTF-8 + + + + + + + com.muyu + cloud-common-core + + + + + com.xuxueli + xxl-job-core + + + + \ No newline at end of file diff --git a/src/main/java/com/muyu/common/xxl/XXLJobConfig.java b/src/main/java/com/muyu/common/xxl/XXLJobConfig.java new file mode 100644 index 0000000..0bf4362 --- /dev/null +++ b/src/main/java/com/muyu/common/xxl/XXLJobConfig.java @@ -0,0 +1,28 @@ +package com.muyu.common.xxl; + +import com.muyu.common.core.utils.StringUtils; +import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +import lombok.extern.log4j.Log4j2; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Log4j2 +@Component +public class XXLJobConfig { + @Bean + public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) { + if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){ + throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项,xxl-job共享配置[application-xxl-config]"); + } + XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); + xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses()); + xxlJobSpringExecutor.setAppname(xxlJobProperties.getAppName()); + xxlJobSpringExecutor.setIp(xxlJobProperties.getIp()); + xxlJobSpringExecutor.setPort(xxlJobProperties.getPort()); + xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken()); + xxlJobSpringExecutor.setLogPath(xxlJobProperties.getLogPath()); + xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getLogRetentionDays()); + log.info(">>>>>>>>>>> xxl-job config init success."); + return xxlJobSpringExecutor; + } +} diff --git a/src/main/java/com/muyu/common/xxl/XxlJobProperties.java b/src/main/java/com/muyu/common/xxl/XxlJobProperties.java new file mode 100644 index 0000000..c1428f7 --- /dev/null +++ b/src/main/java/com/muyu/common/xxl/XxlJobProperties.java @@ -0,0 +1,63 @@ +package com.muyu.common.xxl; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Data +@Configuration +@ConfigurationProperties(prefix = "xxl-job") +public class XxlJobProperties { + + /** + * 调度中心部署根地址 [选填]: + * 如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调"; + * 为空则关闭自动注册; + */ + private String adminAddresses; + + /** + * 执行器通讯TOKEN [选填]: + * 非空时启用; + */ + private String accessToken; + + /** + * 执行器AppName [选填]: + * 执行器心跳注册分组依据;为空则关闭自动注册 + */ + private String appName; + + /** + * 执行器注册 [选填]: + * 优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。 + * 从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。 + */ + private String address; + + /** + * 执行器IP [选填]: + * 默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用; + * 地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; + */ + private String ip; + + /** + * 执行器端口号 [选填]: + * 小于等于0则自动获取;默认端口为9999, + * 单机部署多个执行器时,注意要配置不同执行器端口; + */ + private int port; + + /** + * 执行器运行日志文件存储磁盘路径 [选填]: + * 需要对该路径拥有读写权限;为空则使用默认路径; + */ + private String logPath; + + /** + * 执行器日志文件保存天数 [选填]: + * 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; + */ + private int logRetentionDays; +} diff --git a/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java b/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java new file mode 100644 index 0000000..9b5dabf --- /dev/null +++ b/src/main/java/com/muyu/common/xxl/demo/XxlJobDemoService.java @@ -0,0 +1,28 @@ +package com.muyu.common.xxl.demo; + +import com.xxl.job.core.context.XxlJobHelper; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Component; + +@Log4j2 +@Component +public class XxlJobDemoService { + + /** + * 无参测试 + */ + @XxlJob("xxl-job-demo-no-param") + public void xxlJobDemoNoParam(){ + log.info("调度名称:[{}] - 无参", "xxl-job-demo-no-param"); + } + + /** + * 有参测试 + */ + @XxlJob("xxl-job-demo-one-param") + public void xxlJobDemoOneParam(){ + String param = XxlJobHelper.getJobParam(); + log.info("调度名称:[{}] - 参数:[{}]", "xxl-job-demo-one-param", param); + } +} diff --git a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..1404a51 --- /dev/null +++ b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,3 @@ +com.muyu.common.xxl.XXLJobConfig +com.muyu.common.xxl.XxlJobProperties +com.muyu.common.xxl.demo.XxlJobDemoService \ No newline at end of file diff --git a/target/classes/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/target/classes/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..1404a51 --- /dev/null +++ b/target/classes/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,3 @@ +com.muyu.common.xxl.XXLJobConfig +com.muyu.common.xxl.XxlJobProperties +com.muyu.common.xxl.demo.XxlJobDemoService \ No newline at end of file diff --git a/target/classes/com/muyu/common/xxl/XXLJobConfig.class b/target/classes/com/muyu/common/xxl/XXLJobConfig.class new file mode 100644 index 0000000..cd91475 Binary files /dev/null and b/target/classes/com/muyu/common/xxl/XXLJobConfig.class differ diff --git a/target/classes/com/muyu/common/xxl/XxlJobProperties.class b/target/classes/com/muyu/common/xxl/XxlJobProperties.class new file mode 100644 index 0000000..5663724 Binary files /dev/null and b/target/classes/com/muyu/common/xxl/XxlJobProperties.class differ diff --git a/target/classes/com/muyu/common/xxl/demo/XxlJobDemoService.class b/target/classes/com/muyu/common/xxl/demo/XxlJobDemoService.class new file mode 100644 index 0000000..4ec617a Binary files /dev/null and b/target/classes/com/muyu/common/xxl/demo/XxlJobDemoService.class differ diff --git a/target/cloud-common-xxl-3.6.3.jar b/target/cloud-common-xxl-3.6.3.jar new file mode 100644 index 0000000..8161874 Binary files /dev/null and b/target/cloud-common-xxl-3.6.3.jar differ diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..167cf6b --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Wed Jul 24 20:47:47 CST 2024 +groupId=com.muyu +artifactId=cloud-common-xxl +version=3.6.3 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..62a3aaa --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +com\muyu\common\xxl\demo\XxlJobDemoService.class +com\muyu\common\xxl\XXLJobConfig.class +com\muyu\common\xxl\XxlJobProperties.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..bbc17f3 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,3 @@ +D:\workspace-IceCeram-Cloud-master\zglchaifen\cloud-common-xxl\src\main\java\com\muyu\common\xxl\demo\XxlJobDemoService.java +D:\workspace-IceCeram-Cloud-master\zglchaifen\cloud-common-xxl\src\main\java\com\muyu\common\xxl\XxlJobProperties.java +D:\workspace-IceCeram-Cloud-master\zglchaifen\cloud-common-xxl\src\main\java\com\muyu\common\xxl\XXLJobConfig.java