Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
a1755156
提交
a1755156
authored
9月 15, 2018
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
跨平台:除了提供Java、Python、PHP等十来种任务模式之外,新增提供基于HTTP的任务模式;
上级
d6dc40b4
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
320 行增加
和
4 行删除
+320
-4
XXL-JOB官方文档.md
doc/XXL-JOB官方文档.md
+7
-1
JFinalCoreConfig.java
...xueli/executor/sample/jfinal/config/JFinalCoreConfig.java
+2
-0
HttpJobHandler.java
...eli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
+77
-0
ShardingJobHandler.java
...executor/sample/jfinal/jobhandler/ShardingJobHandler.java
+0
-1
HttpJobHandler.java
...xueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
+78
-0
HttpJobHandler.java
...m/xxl/job/executor/service/jobhandler/HttpJobHandler.java
+78
-0
ShardingJobHandler.java
...l/job/executor/service/jobhandler/ShardingJobHandler.java
+0
-1
HttpJobHandler.java
...m/xxl/job/executor/service/jobhandler/HttpJobHandler.java
+78
-0
ShardingJobHandler.java
...l/job/executor/service/jobhandler/ShardingJobHandler.java
+0
-1
没有找到文件。
doc/XXL-JOB官方文档.md
浏览文件 @
a1755156
...
...
@@ -955,6 +955,11 @@ echo "分片总数 total = $3"
需要注意的是,任务超时中断时与任务终止机制(可查看“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]
...
...
@@ -1244,7 +1249,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
28、新增任务运行模式 "GLUE模式(PowerShell) ",支持PowerShell脚本任务;
-
29、GLUE脚本文件自动清理功能,及时清理过期脚本文件;
-
30、执行器注册方式切换优化,切换自动注册时主动同步在线机器,避免执行器为空的问题;
-
31、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
-
31、跨平台:除了提供Java、Python、PHP等十来种任务模式之外,新增提供基于HTTP的任务模式;
-
32、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
### 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;
import
com.jfinal.kit.PropKit
;
import
com.xuxueli.executor.sample.jfinal.controller.IndexController
;
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.xxl.job.core.executor.XxlJobExecutor
;
import
org.slf4j.Logger
;
...
...
@@ -23,6 +24,7 @@ public class JFinalCoreConfig extends JFinalConfig {
// registry jobhandler
XxlJobExecutor
.
registJobHandler
(
"demoJobHandler"
,
new
DemoJobHandler
());
XxlJobExecutor
.
registJobHandler
(
"shardingJobHandler"
,
new
ShardingJobHandler
());
XxlJobExecutor
.
registJobHandler
(
"httpJobHandler"
,
new
HttpJobHandler
());
// load executor prop
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;
import
com.xxl.job.core.log.XxlJobLogger
;
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;
import
com.xxl.job.core.util.ShardingUtil
;
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;
import
com.xxl.job.core.util.ShardingUtil
;
import
org.springframework.stereotype.Service
;
/**
* 分片广播任务
*
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论