Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix-sample
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mall
arch
matrix-sample
Commits
e8f4fb9d
Commit
e8f4fb9d
authored
Mar 16, 2020
by
qiuweili123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重建结构
parent
7777f138
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
871 additions
and
3 deletions
+871
-3
.gitignore
.gitignore
+32
-0
README.md
README.md
+5
-0
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-api/pom.xml
+28
-0
User.java
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/bean/User.java
+21
-0
UserDService.java
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/service/UserDService.java
+11
-0
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-spring/pom.xml
+16
-0
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/pom.xml
+16
-0
pom.xml
matrix-sample-dubbo/pom.xml
+22
-0
pom.xml
matrix-sample-xxl/matrix-sample-xxl-biz/pom.xml
+21
-0
CommandJobHandler.java
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/CommandJobHandler.java
+58
-0
DemoJobHandler.java
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/DemoJobHandler.java
+39
-0
HttpJobHandler.java
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/HttpJobHandler.java
+85
-0
ShardingJobHandler.java
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/ShardingJobHandler.java
+38
-0
SampleXxlJob.java
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/xxljob/SampleXxlJob.java
+195
-0
pom.xml
matrix-sample-xxl/matrix-sample-xxl-spring/pom.xml
+25
-0
applicationcontext-xxl-job.xml
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/applicationcontext-xxl-job.xml
+40
-0
log4j.xml
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/log4j.xml
+34
-0
logback-secoo.xml
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/logback-secoo.xml
+30
-0
web.xml
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/webapp/WEB-INF/web.xml
+32
-0
index.html
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/webapp/index.html
+2
-0
xxl-job-executor.properties
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/xxl-job-executor.properties
+15
-0
pom.xml
matrix-sample-xxl/matrix-sample-xxl-springboot/pom.xml
+29
-0
XxlJobExecutorApplication.java
matrix-sample-xxl/matrix-sample-xxl-springboot/src/main/java/com/secoo/mall/xxl/XxlJobExecutorApplication.java
+17
-0
application.yml
matrix-sample-xxl/matrix-sample-xxl-springboot/src/main/resources/application.yml
+19
-0
pom.xml
matrix-sample-xxl/pom.xml
+31
-0
pom.xml
pom.xml
+10
-3
No files found.
.gitignore
View file @
e8f4fb9d
!.mvn/wrapper/maven-wrapper.jar
*.class
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
*.lst
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/mvnw
/mvnw.cmd
# "temporary" build files
target/
out/
build/
logs
README.md
0 → 100644
View file @
e8f4fb9d
# 简介
Matrix-sample是matrix组件的示例项目,包括redis、rocketmq等中间件以及提供通用util工具类使用方式等
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-api/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-api
</artifactId>
<dependencies>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
1.5.22
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-core
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/bean/User.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
dubbo
.
bean
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
public
class
User
implements
Serializable
{
@ApiModelProperty
(
value
=
"用户姓名"
)
private
String
name
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/service/UserDService.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
dubbo
.
service
;
import
com.secoo.mall.common.core.bean.BizResponse
;
import
com.secoo.mall.dubbo.bean.User
;
public
interface
UserDService
{
BizResponse
<
String
>
sayHello
(
String
name
);
User
getByid
(
Long
id
);
}
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-spring/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-spring
</artifactId>
</project>
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
</project>
\ No newline at end of file
matrix-sample-dubbo/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
matrix-sample-dubbo-api
</module>
<module>
matrix-sample-dubbo-spring
</module>
<module>
matrix-sample-dubbo-springboot
</module>
</modules>
</project>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-biz/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample-xxl
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-xxl-biz
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-job-xxl-core
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/CommandJobHandler.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
xxl
.
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.springframework.stereotype.Component
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
/**
* 命令行任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
@JobHandler
(
value
=
"commandJobHandler"
)
@Component
public
class
CommandJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
String
command
=
param
;
int
exitValue
=
-
1
;
BufferedReader
bufferedReader
=
null
;
try
{
// command process
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
BufferedInputStream
bufferedInputStream
=
new
BufferedInputStream
(
process
.
getInputStream
());
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
bufferedInputStream
));
// command log
String
line
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
XxlJobLogger
.
log
(
line
);
}
// command exit
process
.
waitFor
();
exitValue
=
process
.
exitValue
();
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
}
finally
{
if
(
bufferedReader
!=
null
)
{
bufferedReader
.
close
();
}
}
if
(
exitValue
==
0
)
{
return
IJobHandler
.
SUCCESS
;
}
else
{
return
new
ReturnT
<
String
>(
IJobHandler
.
FAIL
.
getCode
(),
"command exit value("
+
exitValue
+
") is failed"
);
}
}
}
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/DemoJobHandler.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
xxl
.
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.springframework.stereotype.Component
;
import
java.util.concurrent.TimeUnit
;
/**
* 任务Handler示例(Bean模式)
*
* 开发步骤:
* 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
* 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例;
* 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
* 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*
* @author xuxueli 2015-12-19 19:43:36
*/
@JobHandler
(
value
=
"demoJobHandler"
)
@Component
public
class
DemoJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
XxlJobLogger
.
log
(
"XXL-JOB, Hello World."
);
System
.
out
.
println
(
"DemoJobHandler"
);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
XxlJobLogger
.
log
(
"beat at:"
+
i
);
TimeUnit
.
SECONDS
.
sleep
(
2
);
}
return
SUCCESS
;
}
}
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/HttpJobHandler.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
xxl
.
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.springframework.stereotype.Component
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
/**
* 跨平台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
{
// request
HttpURLConnection
connection
=
null
;
BufferedReader
bufferedReader
=
null
;
try
{
// connection
URL
realUrl
=
new
URL
(
param
);
connection
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
// connection setting
connection
.
setRequestMethod
(
"GET"
);
connection
.
setDoOutput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setConnectTimeout
(
3
*
1000
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"application/json;charset=UTF-8"
);
// do connection
connection
.
connect
();
//Map<String, List<String>> map = connection.getHeaderFields();
// valid StatusCode
int
statusCode
=
connection
.
getResponseCode
();
if
(
statusCode
!=
200
)
{
throw
new
RuntimeException
(
"Http Request StatusCode("
+
statusCode
+
") Invalid."
);
}
// result
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
(),
"UTF-8"
));
StringBuilder
result
=
new
StringBuilder
();
String
line
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
String
responseMsg
=
result
.
toString
();
XxlJobLogger
.
log
(
responseMsg
);
return
SUCCESS
;
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
return
FAIL
;
}
finally
{
try
{
if
(
bufferedReader
!=
null
)
{
bufferedReader
.
close
();
}
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
}
catch
(
Exception
e2
)
{
XxlJobLogger
.
log
(
e2
);
}
}
}
}
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/jobhandler/ShardingJobHandler.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
xxl
.
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
com.xxl.job.core.util.ShardingUtil
;
import
org.springframework.stereotype.Component
;
/**
* 分片广播任务
*
* @author xuxueli 2017-07-25 20:56:50
*/
@JobHandler
(
value
=
"shardingJobHandler"
)
@Component
public
class
ShardingJobHandler
extends
IJobHandler
{
@Override
public
ReturnT
<
String
>
execute
(
String
param
)
throws
Exception
{
// 分片参数
ShardingUtil
.
ShardingVO
shardingVO
=
ShardingUtil
.
getShardingVo
();
XxlJobLogger
.
log
(
"分片参数:当前分片序号 = {}, 总分片数 = {}"
,
shardingVO
.
getIndex
(),
shardingVO
.
getTotal
());
// 业务逻辑
for
(
int
i
=
0
;
i
<
shardingVO
.
getTotal
();
i
++)
{
if
(
i
==
shardingVO
.
getIndex
())
{
XxlJobLogger
.
log
(
"第 {} 片, 命中分片开始处理"
,
i
);
}
else
{
XxlJobLogger
.
log
(
"第 {} 片, 忽略"
,
i
);
}
}
return
SUCCESS
;
}
}
matrix-sample-xxl/matrix-sample-xxl-biz/src/main/java/com/secoo/mall/xxl/xxljob/SampleXxlJob.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
xxl
.
xxljob
;
import
com.secoo.xxl.job.core.handler.annotation.XxlJob
;
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
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.concurrent.TimeUnit
;
/**
* XxlJob开发示例(Bean模式)
* <p>
* 开发步骤:
* 1、在Spring Bean实例中,开发Job方法,方式格式要求为 "public ReturnT<String> execute(String param)"
* 2、为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")",注解value值对应的是调度中心新建任务的JobHandler属性的值。
* 注意事项:
* 1、方法名称必须全局唯一,并且与IJobHandler类名不能有重复
*
* @author xuxueli 2019-12-11 21:52:51
*/
@Component
@Slf4j
public
class
SampleXxlJob
{
/**
* 1、简单任务示例(Bean模式)
*/
@XxlJob
(
"demoJobHandler2"
)
public
ReturnT
<
String
>
demoJobHandler2
(
String
param
)
throws
Exception
{
log
.
info
(
"###demoJobHandler2"
);
XxlJobLogger
.
log
(
"Annotation demoJobHandler XXL-JOB, Hello World."
);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
XxlJobLogger
.
log
(
"beat at:"
+
i
);
TimeUnit
.
SECONDS
.
sleep
(
2
);
}
return
ReturnT
.
SUCCESS
;
}
/**
* 2、分片广播任务
*/
@XxlJob
(
"shardingJobHandler2"
)
public
ReturnT
<
String
>
shardingJobHandler
(
String
param
)
throws
Exception
{
// 分片参数
ShardingUtil
.
ShardingVO
shardingVO
=
ShardingUtil
.
getShardingVo
();
XxlJobLogger
.
log
(
"Annotation 分片参数:当前分片序号 = {}, 总分片数 = {}"
,
shardingVO
.
getIndex
(),
shardingVO
.
getTotal
());
// 业务逻辑
for
(
int
i
=
0
;
i
<
shardingVO
.
getTotal
();
i
++)
{
if
(
i
==
shardingVO
.
getIndex
())
{
XxlJobLogger
.
log
(
"第 {} 片, 命中分片开始处理"
,
i
);
}
else
{
XxlJobLogger
.
log
(
"第 {} 片, 忽略"
,
i
);
}
}
return
ReturnT
.
SUCCESS
;
}
/**
* 3、命令行任务
*/
@XxlJob
(
"commandJobHandler2"
)
public
ReturnT
<
String
>
commandJobHandler
(
String
param
)
throws
Exception
{
String
command
=
param
;
int
exitValue
=
-
1
;
BufferedReader
bufferedReader
=
null
;
try
{
// command process
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
BufferedInputStream
bufferedInputStream
=
new
BufferedInputStream
(
process
.
getInputStream
());
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
bufferedInputStream
));
// command log
String
line
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
XxlJobLogger
.
log
(
line
);
}
// command exit
process
.
waitFor
();
exitValue
=
process
.
exitValue
();
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
}
finally
{
if
(
bufferedReader
!=
null
)
{
bufferedReader
.
close
();
}
}
if
(
exitValue
==
0
)
{
return
IJobHandler
.
SUCCESS
;
}
else
{
return
new
ReturnT
<
String
>(
IJobHandler
.
FAIL
.
getCode
(),
"command exit value("
+
exitValue
+
") is failed"
);
}
}
/**
* 4、跨平台Http任务
*/
@XxlJob
(
"httpJobHandler2"
)
public
ReturnT
<
String
>
httpJobHandler
(
String
param
)
throws
Exception
{
// request
HttpURLConnection
connection
=
null
;
BufferedReader
bufferedReader
=
null
;
try
{
// connection
URL
realUrl
=
new
URL
(
param
);
connection
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
// connection setting
connection
.
setRequestMethod
(
"GET"
);
connection
.
setDoOutput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setConnectTimeout
(
3
*
1000
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"application/json;charset=UTF-8"
);
// do connection
connection
.
connect
();
//Map<String, List<String>> map = connection.getHeaderFields();
// valid StatusCode
int
statusCode
=
connection
.
getResponseCode
();
if
(
statusCode
!=
200
)
{
throw
new
RuntimeException
(
"Http Request StatusCode("
+
statusCode
+
") Invalid."
);
}
// result
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
(),
"UTF-8"
));
StringBuilder
result
=
new
StringBuilder
();
String
line
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
String
responseMsg
=
result
.
toString
();
XxlJobLogger
.
log
(
responseMsg
);
return
ReturnT
.
SUCCESS
;
}
catch
(
Exception
e
)
{
XxlJobLogger
.
log
(
e
);
return
ReturnT
.
FAIL
;
}
finally
{
try
{
if
(
bufferedReader
!=
null
)
{
bufferedReader
.
close
();
}
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
}
catch
(
Exception
e2
)
{
XxlJobLogger
.
log
(
e2
);
}
}
}
/**
* 5、生命周期任务示例:任务初始化与销毁时,支持自定义相关逻辑;
*/
@XxlJob
(
value
=
"springBeanJobHandler2"
,
init
=
"init"
,
destroy
=
"destroy"
)
public
ReturnT
<
String
>
springBeanJobHandler2
(
String
param
)
throws
Exception
{
XxlJobLogger
.
log
(
"XXL-JOB, Hello World."
);
return
ReturnT
.
SUCCESS
;
}
public
void
init
()
{
log
.
info
(
"init"
);
}
public
void
destroy
()
{
log
.
info
(
"destory"
);
}
}
matrix-sample-xxl/matrix-sample-xxl-spring/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample-xxl
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-xxl-spring
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-xxl-biz
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/applicationcontext-xxl-job.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:apollo=
"http://www.ctrip.com/schema/apollo"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.ctrip.com/schema/apollo http://www.ctrip.com/schema/apollo.xsd"
>
<context:property-placeholder
location=
"classpath*:*.properties"
/>
<!-- 这个是最简单的配置形式,一般应用用这种形式就可以了,用来指示Apollo注入application namespace的配置到Spring环境中 -->
<apollo:config/>
<!-- ********************************* 基础配置 ********************************* -->
<!-- 配置01、JobHandler 扫描路径 -->
<context:component-scan
base-package=
"com.secoo.mall.xxl"
/>
<!-- 配置02、执行器 -->
<bean
id=
"xxlJobSpringExecutor"
class=
"com.secoo.xxl.job.core.executor.impl.XxlJobSpringExecutor"
init-method=
"start"
destroy-method=
"destroy"
>
<!-- 执行器注册中心地址[选填],为空则关闭自动注册 -->
<property
name=
"adminAddresses"
value=
"${xxl.job.admin-addresses}"
/>
<!-- 执行器AppName[选填],为空则关闭自动注册.如果接入配置中心,默认会读取app.properties中的app.id-->
<property
name=
"appName"
value=
"${xxl.job.appname}"
/>
<!-- 执行器IP[选填],为空则自动获取 -->
<property
name=
"ip"
value=
"${xxl.job.executor.ip}"
/>
<!-- 执行器端口号[选填],小于等于0则自动获取 -->
<property
name=
"port"
value=
"${xxl.job.executor.port}"
/>
<!-- 访问令牌[选填],非空则进行匹配校验 -->
<property
name=
"accessToken"
value=
"${xxl.job.accessToken}"
/>
<!-- 执行器日志路径[选填],为空则使用默认路径 -->
<property
name=
"logPath"
value=
"${xxl.job.logpath}"
/>
<!-- 日志保存天数[选填],值大于3时生效 -->
<property
name=
"logRetentionDays"
value=
"${xxl.job.logretentiondays}"
/>
</bean>
</beans>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/log4j.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration
xmlns:log4j=
"http://jakarta.apache.org/log4j/"
threshold=
"null"
debug=
"null"
>
<appender
name=
"CONSOLE"
class=
"org.apache.log4j.ConsoleAppender"
>
<param
name=
"Target"
value=
"System.out"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<param
name=
"ConversionPattern"
value=
"%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-sample-spring [%c]-[%t]-[%M]-[%L]-[%p] %m%n"
/>
</layout>
</appender>
<appender
name=
"FILE"
class=
"org.apache.log4j.DailyRollingFileAppender"
>
<param
name=
"file"
value=
"/data/applogs/xxl-job/xxl-job-executor-sample-spring.log"
/>
<param
name=
"append"
value=
"true"
/>
<param
name=
"encoding"
value=
"UTF-8"
/>
<layout
class=
"org.apache.log4j.PatternLayout"
>
<param
name=
"ConversionPattern"
value=
"%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-sample-spring [%c]-[%t]-[%M]-[%L]-[%p] %m%n"
/>
</layout>
</appender>
<root>
<level
value=
"INFO"
/>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"FILE"
/>
</root>
<!--<logger name="com.xxl.job.executor.service.jobhandler" additivity="false">
<level value="INFO" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>-->
</log4j:configuration>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/logback-secoo.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<configuration
debug=
"false"
scan=
"true"
scanPeriod=
"1 seconds"
>
<contextName>
logback
</contextName>
<property
name=
"log.path"
value=
"/data/applogs/xxl-job/xxl-job-executor-sample-springboot.log"
/>
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<pattern>
%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender
name=
"file"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${log.path}
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${log.path}.%d{yyyy-MM-dd}.zip
</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>
%date %level [%thread] %logger{36} [%file : %line] %msg%n
</pattern>
</encoder>
</appender>
<root
level=
"info"
>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"file"
/>
</root>
</configuration>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/webapp/WEB-INF/web.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
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"
>
<display-name>
xxl-job-executor-sample-spring
</display-name>
<context-param>
<param-name>
webAppRootKey
</param-name>
<param-value>
xxl-job-executor-sample-spring
</param-value>
</context-param>
<!-- spring -->
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
classpath*:applicationcontext-*.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
</welcome-file-list>
</web-app>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/webapp/index.html
0 → 100644
View file @
e8f4fb9d
i am alive.
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-spring/src/main/resources/xxl-job-executor.properties
0 → 100644
View file @
e8f4fb9d
#### 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 address
#xxl.job.appname=xxl-job-app
#xxl.job.executor.ip=
#xxl.job.executor.port=9998
#
#### xxl-job, access token
#xxl.job.accessToken=
#
#### xxl-job log path
#xxl.job.logpath=/data/applogs/xxl-job/jobhandler
#### xxl-job log retention days
#xxl.job.logretentiondays=-1
matrix-sample-xxl/matrix-sample-xxl-springboot/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample-xxl
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-xxl-springboot
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-xxl-biz
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-job-xxl-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-springboot/src/main/java/com/secoo/mall/xxl/XxlJobExecutorApplication.java
0 → 100644
View file @
e8f4fb9d
package
com
.
secoo
.
mall
.
xxl
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
/**
* @author xuxueli 2018-10-28 00:38:13
*/
@SpringBootApplication
public
class
XxlJobExecutorApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
XxlJobExecutorApplication
.
class
,
args
);
}
}
\ No newline at end of file
matrix-sample-xxl/matrix-sample-xxl-springboot/src/main/resources/application.yml
0 → 100644
View file @
e8f4fb9d
server
:
port
:
8081
spring
:
application
:
name
:
xxl-job-app
xxl
:
job
:
admin-addresses
:
http://job.secoolocal.com
#xxl-admin访问地址,必填。如开发环境 http://job.secoolocal.com
#executor:
# ip: 127.0.0.1 # 定时任务执行主机IP,非必填。默认为空
# port: #定时任务执行主机端口,非必填。默认9999.
#access-token: #默认为空
#log-path: #xxl日志存储地址,非必填。目录默认位置:c:/opt(windows)或者/data/logs(linux)
#log-retention-days: #日志保存时间,非必填。默认7天
#app-name: # 执行器名称,非必填。默认会读取spring.application.name
# enabled: 是否启用xxl,默认为true。
matrix-sample-xxl/pom.xml
0 → 100644
View file @
e8f4fb9d
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-xxl
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
matrix-sample-xxl-spring
</module>
<module>
matrix-sample-xxl-springboot
</module>
<module>
matrix-sample-xxl-biz
</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-xxl-biz
</artifactId>
<version>
1.3.2.RELEASE
</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
\ No newline at end of file
pom.xml
View file @
e8f4fb9d
...
@@ -3,10 +3,18 @@
...
@@ -3,10 +3,18 @@
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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>
<packaging>
pom
</packaging>
<modules>
<module>
matrix-sample-xxl
</module>
<module>
matrix-sample-dubbo
</module>
</modules>
<parent>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix
</artifactId>
<version>
1.3.2.RELEASE
</version>
</parent>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</project>
</project>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment