Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
aboota
xxl-job
提交
a1755156
X
xxl-job
项目概览
aboota
/
xxl-job
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
xxl-job
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a1755156
编写于
9月 16, 2018
作者:
许雪里
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
跨平台:除了提供Java、Python、PHP等十来种任务模式之外,新增提供基于HTTP的任务模式;
上级
d6dc40b4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
320 addition
and
4 deletion
+320
-4
doc/XXL-JOB官方文档.md
doc/XXL-JOB官方文档.md
+7
-1
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java
...xueli/executor/sample/jfinal/config/JFinalCoreConfig.java
+2
-0
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
...eli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
+77
-0
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/ShardingJobHandler.java
...executor/sample/jfinal/jobhandler/ShardingJobHandler.java
+0
-1
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
...xueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
+78
-0
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
...m/xxl/job/executor/service/jobhandler/HttpJobHandler.java
+78
-0
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
...l/job/executor/service/jobhandler/ShardingJobHandler.java
+0
-1
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
...m/xxl/job/executor/service/jobhandler/HttpJobHandler.java
+78
-0
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
...l/job/executor/service/jobhandler/ShardingJobHandler.java
+0
-1
未找到文件。
doc/XXL-JOB官方文档.md
浏览文件 @
a1755156
...
@@ -955,6 +955,11 @@ echo "分片总数 total = $3"
...
@@ -955,6 +955,11 @@ echo "分片总数 total = $3"
需要注意的是,任务超时中断时与任务终止机制(可查看“4.8 终止运行中的任务”)类似,也是通过 "interrupt" 中断任务,因此业务代码需要将 "InterruptedException" 外抛,否则功能不可用。
需要注意的是,任务超时中断时与任务终止机制(可查看“4.8 终止运行中的任务”)类似,也是通过 "interrupt" 中断任务,因此业务代码需要将 "InterruptedException" 外抛,否则功能不可用。
### 5.17 跨平台 & 跨语言
跨平台、跨语言主要体现在以下两个方面:
-
1、提供Java、Python、PHP……等十来种任务模式,可参考章节 “5.5 任务 "运行模式" ”;理论上可扩展任意语言任务模式;
-
2、提供基于HTTP的任务Handler(Bean任务,JobHandler="httpJobHandler");业务方只需要提供HTTP链接即可,不限制语言、平台;
## 六、版本更新日志
## 六、版本更新日志
### 6.1 版本 V1.1.x,新特性[2015-12-05]
### 6.1 版本 V1.1.x,新特性[2015-12-05]
...
@@ -1244,7 +1249,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -1244,7 +1249,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
28、新增任务运行模式 "GLUE模式(PowerShell) ",支持PowerShell脚本任务;
-
28、新增任务运行模式 "GLUE模式(PowerShell) ",支持PowerShell脚本任务;
-
29、GLUE脚本文件自动清理功能,及时清理过期脚本文件;
-
29、GLUE脚本文件自动清理功能,及时清理过期脚本文件;
-
30、执行器注册方式切换优化,切换自动注册时主动同步在线机器,避免执行器为空的问题;
-
30、执行器注册方式切换优化,切换自动注册时主动同步在线机器,避免执行器为空的问题;
-
31、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
-
31、跨平台:除了提供Java、Python、PHP等十来种任务模式之外,新增提供基于HTTP的任务模式;
-
32、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
### TODO LIST
### TODO LIST
...
...
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java
浏览文件 @
a1755156
...
@@ -5,6 +5,7 @@ import com.jfinal.kit.Prop;
...
@@ -5,6 +5,7 @@ import com.jfinal.kit.Prop;
import
com.jfinal.kit.PropKit
;
import
com.jfinal.kit.PropKit
;
import
com.xuxueli.executor.sample.jfinal.controller.IndexController
;
import
com.xuxueli.executor.sample.jfinal.controller.IndexController
;
import
com.xuxueli.executor.sample.jfinal.jobhandler.DemoJobHandler
;
import
com.xuxueli.executor.sample.jfinal.jobhandler.DemoJobHandler
;
import
com.xuxueli.executor.sample.jfinal.jobhandler.HttpJobHandler
;
import
com.xuxueli.executor.sample.jfinal.jobhandler.ShardingJobHandler
;
import
com.xuxueli.executor.sample.jfinal.jobhandler.ShardingJobHandler
;
import
com.xxl.job.core.executor.XxlJobExecutor
;
import
com.xxl.job.core.executor.XxlJobExecutor
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -23,6 +24,7 @@ public class JFinalCoreConfig extends JFinalConfig {
...
@@ -23,6 +24,7 @@ public class JFinalCoreConfig extends JFinalConfig {
// registry jobhandler
// registry jobhandler
XxlJobExecutor
.
registJobHandler
(
"demoJobHandler"
,
new
DemoJobHandler
());
XxlJobExecutor
.
registJobHandler
(
"demoJobHandler"
,
new
DemoJobHandler
());
XxlJobExecutor
.
registJobHandler
(
"shardingJobHandler"
,
new
ShardingJobHandler
());
XxlJobExecutor
.
registJobHandler
(
"shardingJobHandler"
,
new
ShardingJobHandler
());
XxlJobExecutor
.
registJobHandler
(
"httpJobHandler"
,
new
HttpJobHandler
());
// load executor prop
// load executor prop
Prop
xxlJobProp
=
PropKit
.
use
(
"xxl-job-executor.properties"
);
Prop
xxlJobProp
=
PropKit
.
use
(
"xxl-job-executor.properties"
);
...
...
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
0 → 100644
浏览文件 @
a1755156
package
com.xuxueli.executor.sample.jfinal.jobhandler
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.util.ShardingUtil
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
public
class
HttpJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
// valid
if
(
param
==
null
||
param
.
trim
().
length
()==
0
)
{
XxlJobLogger
.
log
(
"URL Empty"
);
return
FAIL
;
}
// httpGet config
HttpGet
httpGet
=
new
HttpGet
(
param
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
).
setConnectTimeout
(
5000
).
build
();
httpGet
.
setConfig
(
requestConfig
);
CloseableHttpClient
httpClient
=
null
;
try
{
httpClient
=
HttpClients
.
custom
().
disableAutomaticRetries
().
build
();
// parse response
HttpResponse
response
=
httpClient
.
execute
(
httpGet
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
response
.
getStatusLine
().
getStatusCode
()
!=
200
)
{
XxlJobLogger
.
log
(
"Http StatusCode({}) Invalid."
,
response
.
getStatusLine
().
getStatusCode
());
return
FAIL
;
}
if
(
null
==
entity
)
{
XxlJobLogger
.
log
(
"Http Entity Empty."
);
return
FAIL
;
}
String
responseMsg
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
XxlJobLogger
.
log
(
responseMsg
);
EntityUtils
.
consume
(
entity
);
return
SUCCESS
;
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
return
FAIL
;
}
finally
{
if
(
httpGet
!=
null
)
{
httpGet
.
releaseConnection
();
}
if
(
httpClient
!=
null
)
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
XxlJobLogger
.
log
(
e
);
}
}
}
}
}
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/ShardingJobHandler.java
浏览文件 @
a1755156
...
@@ -5,7 +5,6 @@ import com.xxl.job.core.handler.IJobHandler;
...
@@ -5,7 +5,6 @@ import com.xxl.job.core.handler.IJobHandler;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.util.ShardingUtil
;
import
com.xxl.job.core.util.ShardingUtil
;
/**
/**
* 分片广播任务
* 分片广播任务
*
*
...
...
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
0 → 100644
浏览文件 @
a1755156
package
com.xuxueli.executor.sample.nutz.jobhandler
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.annotation.JobHandler
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.nutz.ioc.loader.annotation.IocBean
;
import
java.io.IOException
;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
@JobHandler
(
value
=
"httpJobHandler"
)
@IocBean
public
class
HttpJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
// valid
if
(
param
==
null
||
param
.
trim
().
length
()==
0
)
{
XxlJobLogger
.
log
(
"URL Empty"
);
return
FAIL
;
}
// httpGet config
HttpGet
httpGet
=
new
HttpGet
(
param
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
).
setConnectTimeout
(
5000
).
build
();
httpGet
.
setConfig
(
requestConfig
);
CloseableHttpClient
httpClient
=
null
;
try
{
httpClient
=
HttpClients
.
custom
().
disableAutomaticRetries
().
build
();
// parse response
HttpResponse
response
=
httpClient
.
execute
(
httpGet
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
response
.
getStatusLine
().
getStatusCode
()
!=
200
)
{
XxlJobLogger
.
log
(
"Http StatusCode({}) Invalid."
,
response
.
getStatusLine
().
getStatusCode
());
return
FAIL
;
}
if
(
null
==
entity
)
{
XxlJobLogger
.
log
(
"Http Entity Empty."
);
return
FAIL
;
}
String
responseMsg
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
XxlJobLogger
.
log
(
responseMsg
);
EntityUtils
.
consume
(
entity
);
return
SUCCESS
;
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
return
FAIL
;
}
finally
{
if
(
httpGet
!=
null
)
{
httpGet
.
releaseConnection
();
}
if
(
httpClient
!=
null
)
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
XxlJobLogger
.
log
(
e
);
}
}
}
}
}
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
0 → 100644
浏览文件 @
a1755156
package
com.xxl.job.executor.service.jobhandler
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.annotation.JobHandler
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
@JobHandler
(
value
=
"httpJobHandler"
)
@Component
public
class
HttpJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
// valid
if
(
param
==
null
||
param
.
trim
().
length
()==
0
)
{
XxlJobLogger
.
log
(
"URL Empty"
);
return
FAIL
;
}
// httpGet config
HttpGet
httpGet
=
new
HttpGet
(
param
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
).
setConnectTimeout
(
5000
).
build
();
httpGet
.
setConfig
(
requestConfig
);
CloseableHttpClient
httpClient
=
null
;
try
{
httpClient
=
HttpClients
.
custom
().
disableAutomaticRetries
().
build
();
// parse response
HttpResponse
response
=
httpClient
.
execute
(
httpGet
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
response
.
getStatusLine
().
getStatusCode
()
!=
200
)
{
XxlJobLogger
.
log
(
"Http StatusCode({}) Invalid."
,
response
.
getStatusLine
().
getStatusCode
());
return
FAIL
;
}
if
(
null
==
entity
)
{
XxlJobLogger
.
log
(
"Http Entity Empty."
);
return
FAIL
;
}
String
responseMsg
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
XxlJobLogger
.
log
(
responseMsg
);
EntityUtils
.
consume
(
entity
);
return
SUCCESS
;
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
return
FAIL
;
}
finally
{
if
(
httpGet
!=
null
)
{
httpGet
.
releaseConnection
();
}
if
(
httpClient
!=
null
)
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
XxlJobLogger
.
log
(
e
);
}
}
}
}
}
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
浏览文件 @
a1755156
...
@@ -7,7 +7,6 @@ import com.xxl.job.core.log.XxlJobLogger;
...
@@ -7,7 +7,6 @@ import com.xxl.job.core.log.XxlJobLogger;
import
com.xxl.job.core.util.ShardingUtil
;
import
com.xxl.job.core.util.ShardingUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
/**
/**
* 分片广播任务
* 分片广播任务
*
*
...
...
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
0 → 100644
浏览文件 @
a1755156
package
com.xxl.job.executor.service.jobhandler
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.annotation.JobHandler
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
@JobHandler
(
value
=
"httpJobHandler"
)
@Component
public
class
HttpJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
// valid
if
(
param
==
null
||
param
.
trim
().
length
()==
0
)
{
XxlJobLogger
.
log
(
"URL Empty"
);
return
FAIL
;
}
// httpGet config
HttpGet
httpGet
=
new
HttpGet
(
param
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
).
setConnectTimeout
(
5000
).
build
();
httpGet
.
setConfig
(
requestConfig
);
CloseableHttpClient
httpClient
=
null
;
try
{
httpClient
=
HttpClients
.
custom
().
disableAutomaticRetries
().
build
();
// parse response
HttpResponse
response
=
httpClient
.
execute
(
httpGet
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
response
.
getStatusLine
().
getStatusCode
()
!=
200
)
{
XxlJobLogger
.
log
(
"Http StatusCode({}) Invalid."
,
response
.
getStatusLine
().
getStatusCode
());
return
FAIL
;
}
if
(
null
==
entity
)
{
XxlJobLogger
.
log
(
"Http Entity Empty."
);
return
FAIL
;
}
String
responseMsg
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
XxlJobLogger
.
log
(
responseMsg
);
EntityUtils
.
consume
(
entity
);
return
SUCCESS
;
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
return
FAIL
;
}
finally
{
if
(
httpGet
!=
null
)
{
httpGet
.
releaseConnection
();
}
if
(
httpClient
!=
null
)
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
XxlJobLogger
.
log
(
e
);
}
}
}
}
}
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/ShardingJobHandler.java
浏览文件 @
a1755156
...
@@ -7,7 +7,6 @@ import com.xxl.job.core.log.XxlJobLogger;
...
@@ -7,7 +7,6 @@ import com.xxl.job.core.log.XxlJobLogger;
import
com.xxl.job.core.util.ShardingUtil
;
import
com.xxl.job.core.util.ShardingUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
/**
/**
* 分片广播任务
* 分片广播任务
*
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录