1.背景
我们项目在用xxl-job的时候,只是用到了简单的定时调度http接口功能,所以,为了减少业务工程的侵入性,我决定把executor(执行器)集成到xxl-job-admin中,这样,我们只用部署一个jar包就实现了一个定时调度服务。我们只用在业务工程中写好任务,通过http对外提供服务,xxl-job使用GLUE(Java)模式去发送http请求调用业务接口即可。
2.改造步骤
2.1下载源码
仓库地址: https://gitee.com/xuxueli0323/xxl-job
2.2修改xxl-job-admin的pom
切换到2.4.0分支,复制一份xxl-job-admin后台管理项目,并用idea重新打开,把源码项目中的doc目录复制到xxl-job-admin中。
默认mysql8,如果用的mysql5.7就换成下面的mysql-connector-java,hutool依赖是用来加到执行器中执行GLUE(Java)中的代码用的。
<!-- mysql8 -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${mysql-connector-j.version}</version>
</dependency>
<!-- mysql5.7 -->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <version>5.1.49</version>-->
<!-- </dependency>-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.22</version>
</dependency>
把Excutor的配置集成到xxl-job-admin中
#2.4.0默认mysql8,下面是需要修改的内容--start----------------------
### xxl-job, datasource
#mysql8
spring.datasource.url=jdbc:mysql://192.168.26.160:3307/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#mysql5.7
#spring.datasource.url=jdbc:mysql://192.168.26.160:3307/xxl_job?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=1234
#2.4.0默认mysql8,下面是需要修改的内容--end-----------------------
#新增执行器配置
#执行器配置start------------------------------------------------
# log config
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 executor appname
xxl.job.executor.appname=xxl-job-scheduler-1-common-excutor
### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
xxl.job.executor.address=
### xxl-job executor server-info
xxl.job.executor.ip=127.0.0.1
xxl.job.executor.port=9999
### xxl-job executor log-path
#修改成./logs/jobhandler,否则查看调度日志时看不到
#xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
xxl.job.executor.logpath=./logs/jobhandler
### xxl-job executor log-retention-days
xxl.job.executor.logretentiondays=30
#执行器配置end------------------------------------------------
标签:admin,mysql,---,job,executor,###,xxl
From: https://www.cnblogs.com/hujunwei/p/17932605.html