Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
85179937
提交
85179937
authored
8月 11, 2017
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
规范项目目录,方便扩展多执行器;
上级
0cb742d6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
28 个修改的文件
包含
200 行增加
和
172 行删除
+200
-172
NOTICE
NOTICE
+1
-1
README.md
README.md
+1
-1
XXL-JOB-English-Documentation.md
doc/XXL-JOB-English-Documentation.md
+0
-0
XXL-JOB官方文档.md
doc/XXL-JOB官方文档.md
+21
-16
tables_mysql(备份,请忽略).sql
doc/db/tables_mysql(备份,请忽略).sql
+0
-0
tables_xxl_job.sql
doc/db/tables_xxl_job.sql
+0
-0
pom.xml
pom.xml
+1
-2
XxlJobExecutor.java
...c/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
+3
-1
XxlJobFileAppender.java
...rc/main/java/com/xxl/job/core/log/XxlJobFileAppender.java
+1
-1
pom.xml
xxl-job-executor-samples/pom.xml
+19
-0
pom.xml
...b-executor-samples/xxl-job-executor-sample-spring/pom.xml
+39
-38
DemoJobHandler.java
...m/xxl/job/executor/service/jobhandler/DemoJobHandler.java
+38
-38
ShardingJobHandler.java
...l/job/executor/service/jobhandler/ShardingJobHandler.java
+0
-0
applicationcontext-xxl-job.xml
...-spring/src/main/resources/applicationcontext-xxl-job.xml
+41
-40
log4j.xml
...l-job-executor-sample-spring/src/main/resources/log4j.xml
+3
-3
xxl-job-executor.properties
...ple-spring/src/main/resources/xxl-job-executor.properties
+1
-1
web.xml
...ob-executor-sample-spring/src/main/webapp/WEB-INF/web.xml
+27
-26
index.html
...xxl-job-executor-sample-spring/src/main/webapp/index.html
+0
-0
DemoJobHandlerTest.java
...c/test/java/com/xxl/executor/test/DemoJobHandlerTest.java
+0
-0
pom.xml
...ecutor-samples/xxl-job-executor-sample-springboot/pom.xml
+2
-2
Application.java
...gboot/src/main/java/com/xxl/job/executor/Application.java
+0
-0
XxlJobConfig.java
...n/java/com/xxl/job/executor/core/config/XxlJobConfig.java
+0
-0
IndexController.java
.../com/xxl/job/executor/mvc/controller/IndexController.java
+0
-0
DemoJobHandler.java
...m/xxl/job/executor/service/jobhandler/DemoJobHandler.java
+0
-0
ShardingJobHandler.java
...l/job/executor/service/jobhandler/ShardingJobHandler.java
+0
-0
application.properties
...mple-springboot/src/main/resources/application.properties
+1
-1
logback.xml
...executor-sample-springboot/src/main/resources/logback.xml
+1
-1
XxlJobExecutorExampleBootApplicationTests.java
...cutor/test/XxlJobExecutorExampleBootApplicationTests.java
+0
-0
没有找到文件。
NOTICE
浏览文件 @
85179937
Copyright
2015-2017/NOW
xuxueli.
Copyright
(c) 2015-present,
xuxueli.
Dependencies:
Dependencies:
================================================================
================================================================
...
...
README.md
浏览文件 @
85179937
...
@@ -38,7 +38,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -38,7 +38,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
## Documentation
## Documentation
-
[
中文文档
](
https://github.com/xuxueli/xxl-job/blob/master/doc/XXL-JOB官方文档.md
)
-
[
中文文档
](
https://github.com/xuxueli/xxl-job/blob/master/doc/XXL-JOB官方文档.md
)
-
[
Englis
Documentation
](
https://github.com/xuxueli/xxl-job/blob/master/doc/XXL-JOB-Englis
-Documentation.md
)
-
[
Englis
h Documentation
](
https://github.com/xuxueli/xxl-job/blob/master/doc/XXL-JOB-English
-Documentation.md
)
## Features
## Features
...
...
doc/XXL-JOB-Englis-Documentation.md
→
doc/XXL-JOB-Englis
h
-Documentation.md
浏览文件 @
85179937
File moved
doc/XXL-JOB官方文档.md
浏览文件 @
85179937
...
@@ -122,11 +122,11 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -122,11 +122,11 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
#### 技术交流
#### 技术交流
-
腾讯QQ群(6):399758605
-
腾讯QQ群(6):399758605
-
腾讯QQ群(5):138274130
(群即将满,请加群6)
-
腾讯QQ群(5):138274130
-
腾讯QQ群(4):464762661
(群即将满,请加群6)
-
腾讯QQ群(4):464762661
-
腾讯QQ群(3):242151780
(群即将满,请加群6)
-
腾讯QQ群(3):242151780
-
腾讯QQ群(2):438249535
(群即将满,请加群6)
-
腾讯QQ群(2):438249535
-
腾讯QQ群(1):367260654
(群即将满,请加群6)
-
腾讯QQ群(1):367260654
### 1.5 环境
### 1.5 环境
-
JDK:1.7+
-
JDK:1.7+
...
@@ -144,7 +144,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -144,7 +144,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
"调度数据库初始化SQL脚本" 位置为:
"调度数据库初始化SQL脚本" 位置为:
/xxl-job/db/tables_xxl_job.sql
/xxl-job/d
oc/d
b/tables_xxl_job.sql
调度中心支持集群部署,集群情况下各节点务必连接同一个mysql实例;
调度中心支持集群部署,集群情况下各节点务必连接同一个mysql实例;
...
@@ -155,8 +155,9 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -155,8 +155,9 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
xxl-job-admin:调度中心
xxl-job-admin:调度中心
xxl-job-core:公共依赖
xxl-job-core:公共依赖
xxl-job-executor-example:执行器Example(可直接使用执行器Example,也可以将现有项目改造成执行器使用)
xxl-job-executor:执行器Example项目
xxl-job-executor-springboot-example:执行器Example,springboot版本
:xxl-job-executor-sample-spring:执行器Example,Spring版本(可直接使用执行器Example,也可以将现有项目改造成执行器使用)
:xxl-job-executor-sample-springboot:执行器Example,Springboot版本
### 2.3 配置部署“调度中心”
### 2.3 配置部署“调度中心”
...
@@ -209,7 +210,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -209,7 +210,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
### 2.4 配置部署“执行器项目”
### 2.4 配置部署“执行器项目”
“执行器”项目:xxl-job-executor-
example
(如新建执行器项目,可参考该Example执行器项目的配置步骤;)
“执行器”项目:xxl-job-executor-
sample-spring
(如新建执行器项目,可参考该Example执行器项目的配置步骤;)
作用:负责接收“调度中心”的调度并执行;
作用:负责接收“调度中心”的调度并执行;
#### 步骤一:maven依赖
#### 步骤一:maven依赖
...
@@ -218,7 +219,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -218,7 +219,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
#### 步骤二:执行器配置
#### 步骤二:执行器配置
执行器配置配置文件地址:
执行器配置配置文件地址:
/xxl-job/xxl-job-executor-
example
/src/main/resources/xxl-job-executor.properties
/xxl-job/xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/resources/xxl-job-executor.properties
执行器配置配置内容说明:
执行器配置配置内容说明:
...
@@ -226,7 +227,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -226,7 +227,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
### xxl-job executor address:执行器"AppName"和地址信息配置:AppName执行器心跳注册分组依据;地址信息用于"调度中心请求并触发任务"和"执行器注册"。执行器默认端口为9999,执行器IP默认为空表示自动获取IP,多网卡时可手动设置指定IP。单机部署多个执行器时,注意要配置不同执行器端口;
### xxl-job executor address:执行器"AppName"和地址信息配置:AppName执行器心跳注册分组依据;地址信息用于"调度中心请求并触发任务"和"执行器注册"。执行器默认端口为9999,执行器IP默认为空表示自动获取IP,多网卡时可手动设置指定IP。单机部署多个执行器时,注意要配置不同执行器端口;
xxl.job.executor.appname=xxl-job-executor-
ex
ample
xxl.job.executor.appname=xxl-job-executor-
s
ample
xxl.job.executor.ip=
xxl.job.executor.ip=
xxl.job.executor.port=9999
xxl.job.executor.port=9999
...
@@ -248,8 +249,8 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -248,8 +249,8 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
#### 步骤四:部署执行器项目:
#### 步骤四:部署执行器项目:
如果已经正确进行上述配置,可将执行器项目编译打部署,系统提供两个执行器example项目,选择其中一个即可,各自的部署方式如下。
如果已经正确进行上述配置,可将执行器项目编译打部署,系统提供两个执行器example项目,选择其中一个即可,各自的部署方式如下。
xxl-job-executor-
example
:项目编译打包成WAR包,并部署到tomcat中。
xxl-job-executor-
sample-spring
:项目编译打包成WAR包,并部署到tomcat中。
xxl-job-executor-s
pringboot-example
:项目编译打包成springboot类型的可执行JAR包,命令启动即可;
xxl-job-executor-s
ample-springboot
:项目编译打包成springboot类型的可执行JAR包,命令启动即可;
至此“执行器”项目已经部署结束。
至此“执行器”项目已经部署结束。
...
@@ -326,7 +327,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -326,7 +327,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
- 失败处理策略;调度失败时的处理策略;
- 失败处理策略;调度失败时的处理策略;
失败告警(默认):调度失败时,将会触发失败报警,如发送报警邮件;
失败告警(默认):调度失败时,将会触发失败报警,如发送报警邮件;
失败重试:调度失败时,将会主动进行一次失败重试调度,重试调度后仍然失败将会触发一失败告警。注意当任务以failover方式路由时,每次失败重试将会触发新一轮路由。
失败重试:调度失败时,将会主动进行一次失败重试调度,重试调度后仍然失败将会触发一失败告警。注意当任务以failover方式路由时,每次失败重试将会触发新一轮路由。
- 执行参数:任务执行所需的参数,多个参数时用逗号分隔,任务执行时将会把多个参数
抓
换成数组传入;
- 执行参数:任务执行所需的参数,多个参数时用逗号分隔,任务执行时将会把多个参数
转
换成数组传入;
- 报警邮件:任务调度失败时邮件通知的邮箱地址,支持配置多邮箱地址,配置多个邮箱地址时用逗号分隔;
- 报警邮件:任务调度失败时邮件通知的邮箱地址,支持配置多邮箱地址,配置多个邮箱地址时用逗号分隔;
- 负责人:任务的负责人;
- 负责人:任务的负责人;
...
@@ -337,7 +338,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
...
@@ -337,7 +338,7 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
-
1、 新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
-
1、 新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
-
2、 该类被Spring容器扫描为Bean实例,如加“@Component”注解;
-
2、 该类被Spring容器扫描为Bean实例,如加“@Component”注解;
-
3、 添加 “@JobHander(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
-
3、 添加 “@JobHander(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
(可参考
xxl-job-executor-example项目
中的DemoJobHandler,见下图)
(可参考
Example执行器
中的DemoJobHandler,见下图)


...
@@ -495,7 +496,7 @@ try{
...
@@ -495,7 +496,7 @@ try{
-
/db :“调度数据库”建表脚本
-
/db :“调度数据库”建表脚本
-
/xxl-job-admin :调度中心,项目源码
-
/xxl-job-admin :调度中心,项目源码
-
/xxl-job-core :公共Jar依赖
-
/xxl-job-core :公共Jar依赖
-
/xxl-job-executor-
example :执行器,Demo项目源码
(大家可以在该项目上进行开发,也可以将现有项目改造生成执行器项目)
-
/xxl-job-executor-
samples :执行器,Example项目
(大家可以在该项目上进行开发,也可以将现有项目改造生成执行器项目)
#### 5.2 “调度数据库”配置
#### 5.2 “调度数据库”配置
XXL-JOB调度模块基于Quartz集群实现,其“调度数据库”是在Quartz的11张集群mysql表基础上扩展而成。
XXL-JOB调度模块基于Quartz集群实现,其“调度数据库”是在Quartz的11张集群mysql表基础上扩展而成。
...
@@ -944,6 +945,10 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -944,6 +945,10 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
10、springboot版本执行器,升级至1.5.6.RELEASE版本;
-
10、springboot版本执行器,升级至1.5.6.RELEASE版本;
-
11、统一maven依赖版本管理;
-
11、统一maven依赖版本管理;
#### 6.18 版本 V1.8.2 特性[Coding]
-
1、解决执行器回调URL不支持配置HTTPS时问题;
-
2、规范项目目录,方便扩展多执行器;
#### TODO LIST
#### TODO LIST
-
1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
-
1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
-
2、任务分片路由:分片采用一致性Hash算法计算出尽量稳定的分片顺序,即使注册机器存在波动也不会引起分批分片顺序大的波动;目前采用IP自然排序,可以满足需求,待定;
-
2、任务分片路由:分片采用一致性Hash算法计算出尽量稳定的分片顺序,即使注册机器存在波动也不会引起分批分片顺序大的波动;目前采用IP自然排序,可以满足需求,待定;
...
...
db/tables_mysql(备份,请忽略).sql
→
d
oc/d
b/tables_mysql(备份,请忽略).sql
浏览文件 @
85179937
File moved
db/tables_xxl_job.sql
→
d
oc/d
b/tables_xxl_job.sql
浏览文件 @
85179937
差异被折叠。
点击展开。
pom.xml
浏览文件 @
85179937
...
@@ -13,8 +13,7 @@
...
@@ -13,8 +13,7 @@
<modules>
<modules>
<module>
xxl-job-core
</module>
<module>
xxl-job-core
</module>
<module>
xxl-job-admin
</module>
<module>
xxl-job-admin
</module>
<module>
xxl-job-executor-example
</module>
<module>
xxl-job-executor-samples
</module>
<module>
xxl-job-executor-springboot-example
</module>
</modules>
</modules>
<properties>
<properties>
...
...
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
浏览文件 @
85179937
...
@@ -71,7 +71,9 @@ public class XxlJobExecutor implements ApplicationContextAware {
...
@@ -71,7 +71,9 @@ public class XxlJobExecutor implements ApplicationContextAware {
initAdminBizList
(
adminAddresses
,
accessToken
);
initAdminBizList
(
adminAddresses
,
accessToken
);
// init executor-jobHandlerRepository
// init executor-jobHandlerRepository
initJobHandlerRepository
(
applicationContext
);
if
(
applicationContext
!=
null
)
{
initJobHandlerRepository
(
applicationContext
);
}
// init logpath
// init logpath
if
(
logPath
!=
null
&&
logPath
.
trim
().
length
()>
0
)
{
if
(
logPath
!=
null
&&
logPath
.
trim
().
length
()>
0
)
{
...
...
xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java
浏览文件 @
85179937
...
@@ -18,7 +18,7 @@ public class XxlJobFileAppender {
...
@@ -18,7 +18,7 @@ public class XxlJobFileAppender {
// for JobThread (support log for child thread of job handler)
// for JobThread (support log for child thread of job handler)
//public static ThreadLocal<String> contextHolder = new ThreadLocal<String>();
//public static ThreadLocal<String> contextHolder = new ThreadLocal<String>();
public
static
final
InheritableThreadLocal
<
String
>
contextHolder
=
new
InheritableThreadLocal
<
String
>();
public
static
final
InheritableThreadLocal
<
String
>
contextHolder
=
new
InheritableThreadLocal
<
String
>();
public
static
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
public
static
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// TODO, concurrent issues
public
static
String
logPath
=
"/data/applogs/xxl-job/jobhandler/"
;
public
static
String
logPath
=
"/data/applogs/xxl-job/jobhandler/"
;
/**
/**
...
...
xxl-job-executor-samples/pom.xml
0 → 100644
浏览文件 @
85179937
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job
</artifactId>
<version>
1.8.2-SNAPSHOT
</version>
</parent>
<artifactId>
xxl-job-executor-samples
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
xxl-job-executor-sample-spring
</module>
<module>
xxl-job-executor-sample-springboot
</module>
</modules>
</project>
\ No newline at end of file
xxl-job-executor-
example
/pom.xml
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/pom.xml
浏览文件 @
85179937
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<parent>
<groupId>
com.xuxueli
</groupId>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job
</artifactId>
<artifactId>
xxl-job
-executor-samples
</artifactId>
<version>
1.8.2-SNAPSHOT
</version>
<version>
1.8.2-SNAPSHOT
</version>
</parent>
</parent>
<artifactId>
xxl-job-executor-
example
</artifactId>
<artifactId>
xxl-job-executor-
sample-spring
</artifactId>
<packaging>
war
</packaging>
<packaging>
war
</packaging>
<name>
${project.artifactId}
</name>
<name>
${project.artifactId}
</name>
<description>
Executor project for spring boot.
</description>
<description>
Executor project for spring boot.
</description>
<url>
http://www.xuxueli.com/
</url>
<url>
http://www.xuxueli.com/
</url>
<dependencies>
<dependencies>
<!-- spring-webmvc -->
<!-- spring-webmvc -->
<dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
<artifactId>
spring-webmvc
</artifactId>
<version>
${spring.version}
</version>
<version>
${spring.version}
</version>
</dependency>
</dependency>
<!-- slf4j -->
<!-- slf4j -->
<dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
<artifactId>
slf4j-log4j12
</artifactId>
<version>
${slf4j-api.version}
</version>
<version>
${slf4j-api.version}
</version>
</dependency>
</dependency>
<!-- xxl-job-core -->
<!-- xxl-job-core -->
<dependency>
<dependency>
<groupId>
com.xuxueli
</groupId>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job-core
</artifactId>
<artifactId>
xxl-job-core
</artifactId>
<version>
${project.parent.version}
</version>
<version>
${project.parent.version}
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
xxl-job-executor-
example
/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
浏览文件 @
85179937
package
com
.
xxl
.
job
.
executor
.
service
.
jobhandler
;
package
com
.
xxl
.
job
.
executor
.
service
.
jobhandler
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.annotation.JobHander
;
import
com.xxl.job.core.handler.annotation.JobHander
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* 任务Handler的一个Demo(Bean模式)
* 任务Handler的一个Demo(Bean模式)
*
*
* 开发步骤:
* 开发步骤:
* 1、新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
* 1、新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
* 2、该类被Spring容器扫描为Bean实例,如加“@Component”注解;
* 2、该类被Spring容器扫描为Bean实例,如加“@Component”注解;
* 3、添加 “@JobHander(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
* 3、添加 “@JobHander(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
* 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
* 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*
*
* @author xuxueli 2015-12-19 19:43:36
* @author xuxueli 2015-12-19 19:43:36
*/
*/
@JobHander
(
value
=
"demoJobHandler"
)
@JobHander
(
value
=
"demoJobHandler"
)
@Component
@Component
public
class
DemoJobHandler
extends
IJobHandler
{
public
class
DemoJobHandler
extends
IJobHandler
{
@Override
@Override
public
ReturnT
<
String
>
execute
(
String
...
params
)
throws
Exception
{
public
ReturnT
<
String
>
execute
(
String
...
params
)
throws
Exception
{
XxlJobLogger
.
log
(
"XXL-JOB, Hello World."
);
XxlJobLogger
.
log
(
"XXL-JOB, Hello World."
);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
XxlJobLogger
.
log
(
"beat at:"
+
i
);
XxlJobLogger
.
log
(
"beat at:"
+
i
);
TimeUnit
.
SECONDS
.
sleep
(
2
);
TimeUnit
.
SECONDS
.
sleep
(
2
);
}
}
return
ReturnT
.
SUCCESS
;
return
ReturnT
.
SUCCESS
;
}
}
}
}
xxl-job-executor-
example
/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
浏览文件 @
85179937
File moved
xxl-job-executor-
example
/src/main/resources/applicationcontext-xxl-job.xml
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/resources/applicationcontext-xxl-job.xml
浏览文件 @
85179937
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<bean
id=
"propertyConfigurer"
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<bean
id=
"propertyConfigurer"
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<property
name=
"fileEncoding"
value=
"utf-8"
/>
<property
name=
"fileEncoding"
value=
"utf-8"
/>
<property
name=
"locations"
>
<property
name=
"locations"
>
<list>
<list>
<value>
classpath*:xxl-job-executor.properties
</value>
<value>
classpath*:xxl-job-executor.properties
</value>
</list>
</list>
</property>
</property>
</bean>
</bean>
<!-- ********************************* 基础配置 ********************************* -->
<!-- ********************************* 基础配置 ********************************* -->
<!-- 配置01、JobHandler 扫描路径 -->
<!-- 配置01、JobHandler 扫描路径 -->
<context:component-scan
base-package=
"com.xxl.job.executor.service.jobhandler"
/>
<context:component-scan
base-package=
"com.xxl.job.executor.service.jobhandler"
/>
<!-- 配置02、执行器 -->
<!-- 配置02、执行器 -->
<bean
id=
"xxlJobExecutor"
class=
"com.xxl.job.core.executor.XxlJobExecutor"
init-method=
"start"
destroy-method=
"destroy"
>
<bean
id=
"xxlJobExecutor"
class=
"com.xxl.job.core.executor.XxlJobExecutor"
init-method=
"start"
destroy-method=
"destroy"
>
<!-- 执行器IP[选填],为空则自动获取 -->
<!-- 执行器IP[选填],为空则自动获取 -->
<property
name=
"ip"
value=
"${xxl.job.executor.ip}"
/>
<property
name=
"ip"
value=
"${xxl.job.executor.ip}"
/>
<!-- 执行器端口号[必须] -->
<!-- 执行器端口号[必须] -->
<property
name=
"port"
value=
"${xxl.job.executor.port}"
/>
<property
name=
"port"
value=
"${xxl.job.executor.port}"
/>
<!-- 执行器AppName[选填],为空则关闭自动注册 -->
<!-- 执行器AppName[选填],为空则关闭自动注册 -->
<property
name=
"appName"
value=
"${xxl.job.executor.appname}"
/>
<property
name=
"appName"
value=
"${xxl.job.executor.appname}"
/>
<!-- 执行器注册中心地址[选填],为空则关闭自动注册 -->
<!-- 执行器注册中心地址[选填],为空则关闭自动注册 -->
<property
name=
"adminAddresses"
value=
"${xxl.job.admin.addresses}"
/>
<property
name=
"adminAddresses"
value=
"${xxl.job.admin.addresses}"
/>
<!-- 执行器日志路径[必填] -->
<!-- 执行器日志路径[必填] -->
<property
name=
"logPath"
value=
"${xxl.job.executor.logpath}"
/>
<property
name=
"logPath"
value=
"${xxl.job.executor.logpath}"
/>
<!-- 访问令牌,非空则进行匹配校验[选填] -->
<!-- 访问令牌,非空则进行匹配校验[选填] -->
<property
name=
"accessToken"
value=
"${xxl.job.accessToken}"
/>
<property
name=
"accessToken"
value=
"${xxl.job.accessToken}"
/>
</bean>
</bean>
</beans>
</beans>
\ No newline at end of file
xxl-job-executor-
example
/src/main/resources/log4j.xml
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/resources/log4j.xml
浏览文件 @
85179937
...
@@ -5,16 +5,16 @@
...
@@ -5,16 +5,16 @@
<appender
name=
"CONSOLE"
class=
"org.apache.log4j.ConsoleAppender"
>
<appender
name=
"CONSOLE"
class=
"org.apache.log4j.ConsoleAppender"
>
<param
name=
"Target"
value=
"System.out"
/>
<param
name=
"Target"
value=
"System.out"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<param
name=
"ConversionPattern"
value=
"%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-
example
[%c]-[%t]-[%M]-[%L]-[%p] %m%n"
/>
<param
name=
"ConversionPattern"
value=
"%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-
sample-spring
[%c]-[%t]-[%M]-[%L]-[%p] %m%n"
/>
</layout>
</layout>
</appender>
</appender>
<appender
name=
"FILE"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<appender
name=
"FILE"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<param
name=
"file"
value=
"/data/applogs/xxl-job/xxl-job-executor-
example
.log"
/>
<param
name=
"file"
value=
"/data/applogs/xxl-job/xxl-job-executor-
sample-spring
.log"
/>
<param
name=
"append"
value=
"true"
/>
<param
name=
"append"
value=
"true"
/>
<param
name=
"encoding"
value=
"UTF-8"
/>
<param
name=
"encoding"
value=
"UTF-8"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<param
name=
"ConversionPattern"
value=
"%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-
example
[%c]-[%t]-[%M]-[%L]-[%p] %m%n"
/>
<param
name=
"ConversionPattern"
value=
"%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-
sample-spring
[%c]-[%t]-[%M]-[%L]-[%p] %m%n"
/>
</layout>
</layout>
</appender>
</appender>
...
...
xxl-job-executor-
example
/src/main/resources/xxl-job-executor.properties
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/resources/xxl-job-executor.properties
浏览文件 @
85179937
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
xxl.job.admin.addresses
=
http://127.0.0.1:8080/xxl-job-admin
xxl.job.admin.addresses
=
http://127.0.0.1:8080/xxl-job-admin
### xxl-job executor address
### xxl-job executor address
xxl.job.executor.appname
=
xxl-job-executor-
ex
ample
xxl.job.executor.appname
=
xxl-job-executor-
s
ample
xxl.job.executor.ip
=
xxl.job.executor.ip
=
xxl.job.executor.port
=
9999
xxl.job.executor.port
=
9999
...
...
xxl-job-executor-
example
/src/main/webapp/WEB-INF/web.xml
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/webapp/WEB-INF/web.xml
浏览文件 @
85179937
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<web-app
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:web=
"http://java.sun.com/xml/ns/javaee"
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:web=
"http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id=
"WebApp_ID"
version=
"2.5"
>
id=
"WebApp_ID"
version=
"2.5"
>
<context-param>
<context-param>
<param-name>
webAppRootKey
</param-name>
<param-name>
webAppRootKey
</param-name>
<param-value>
xxl-job-
client-demo
</param-value>
<param-value>
xxl-job-
executor-sample-spring
</param-value>
</context-param>
</context-param>
<context-param>
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-name>
contextConfigLocation
</param-name>
<param-value>
classpath*:applicationcontext-*.xml
</param-value>
<param-value>
classpath*:applicationcontext-*.xml
</param-value>
</context-param>
</context-param>
<listener>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
</listener>
<listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</listener>
<welcome-file-list>
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
<welcome-file>
index.html
</welcome-file>
</welcome-file-list>
</welcome-file-list>
</web-app>
</web-app>
\ No newline at end of file
xxl-job-executor-
example
/src/main/webapp/index.html
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/main/webapp/index.html
浏览文件 @
85179937
File moved
xxl-job-executor-
example
/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java
→
xxl-job-executor-
samples/xxl-job-executor-sample-spring
/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java
浏览文件 @
85179937
File moved
xxl-job-executor-s
pringboot-example
/pom.xml
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/pom.xml
浏览文件 @
85179937
...
@@ -5,10 +5,10 @@
...
@@ -5,10 +5,10 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<parent>
<groupId>
com.xuxueli
</groupId>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job
</artifactId>
<artifactId>
xxl-job
-executor-samples
</artifactId>
<version>
1.8.2-SNAPSHOT
</version>
<version>
1.8.2-SNAPSHOT
</version>
</parent>
</parent>
<artifactId>
xxl-job-executor-s
pringboot-example
</artifactId>
<artifactId>
xxl-job-executor-s
ample-springboot
</artifactId>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<name>
${project.artifactId}
</name>
<name>
${project.artifactId}
</name>
...
...
xxl-job-executor-s
pringboot-example
/src/main/java/com/xxl/job/executor/Application.java
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/java/com/xxl/job/executor/Application.java
浏览文件 @
85179937
File moved
xxl-job-executor-s
pringboot-example
/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java
浏览文件 @
85179937
File moved
xxl-job-executor-s
pringboot-example
/src/main/java/com/xxl/job/executor/mvc/controller/IndexController.java
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/java/com/xxl/job/executor/mvc/controller/IndexController.java
浏览文件 @
85179937
File moved
xxl-job-executor-s
pringboot-example
/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
浏览文件 @
85179937
File moved
xxl-job-executor-s
pringboot-example
/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
浏览文件 @
85179937
File moved
xxl-job-executor-s
pringboot-example
/src/main/resources/application.properties
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/resources/application.properties
浏览文件 @
85179937
...
@@ -9,7 +9,7 @@ logging.config=classpath:logback.xml
...
@@ -9,7 +9,7 @@ logging.config=classpath:logback.xml
xxl.job.admin.addresses
=
http://127.0.0.1:8080/xxl-job-admin
xxl.job.admin.addresses
=
http://127.0.0.1:8080/xxl-job-admin
### xxl-job executor address
### xxl-job executor address
xxl.job.executor.appname
=
xxl-job-executor-
ex
ample
xxl.job.executor.appname
=
xxl-job-executor-
s
ample
xxl.job.executor.ip
=
xxl.job.executor.ip
=
xxl.job.executor.port
=
9998
xxl.job.executor.port
=
9998
...
...
xxl-job-executor-s
pringboot-example
/src/main/resources/logback.xml
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/main/resources/logback.xml
浏览文件 @
85179937
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<configuration
debug=
"false"
scan=
"true"
scanPeriod=
"1 seconds"
>
<configuration
debug=
"false"
scan=
"true"
scanPeriod=
"1 seconds"
>
<contextName>
logback
</contextName>
<contextName>
logback
</contextName>
<property
name=
"log.path"
value=
"/data/applogs/xxl-job/xxl-job-executor-
example
.log"
/>
<property
name=
"log.path"
value=
"/data/applogs/xxl-job/xxl-job-executor-
sample-springboot
.log"
/>
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter" >
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter" >
...
...
xxl-job-executor-s
pringboot-example
/src/test/java/com/xxl/job/executor/test/XxlJobExecutorExampleBootApplicationTests.java
→
xxl-job-executor-s
amples/xxl-job-executor-sample-springboot
/src/test/java/com/xxl/job/executor/test/XxlJobExecutorExampleBootApplicationTests.java
浏览文件 @
85179937
File moved
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论