springboot版本执行器,取消XML配置,改为类配置方式; ( From github user:FelixXu )
This commit is contained in:
parent
628a1ac547
commit
7e651b5504
|
@ -867,6 +867,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
|
||||||
- 6、执行器重复注册问题修复;
|
- 6、执行器重复注册问题修复;
|
||||||
- 7、任务线程轮空30次后自动销毁,降低低频任务的无效线程消耗。
|
- 7、任务线程轮空30次后自动销毁,降低低频任务的无效线程消耗。
|
||||||
- 8、执行器任务执行结果批量回调,降低回调频率提升执行器性能;
|
- 8、执行器任务执行结果批量回调,降低回调频率提升执行器性能;
|
||||||
|
- 9、springboot版本执行器,取消XML配置,改为类配置方式;
|
||||||
|
|
||||||
#### TODO LIST
|
#### TODO LIST
|
||||||
- 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
|
- 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
|
||||||
|
|
|
@ -1,11 +1,46 @@
|
||||||
package com.xxl.job.executor.core.config;
|
package com.xxl.job.executor.core.config;
|
||||||
|
|
||||||
|
import com.xxl.job.core.executor.XxlJobExecutor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ImportResource("classpath:applicationcontext-xxl-job.xml")
|
@ComponentScan(basePackages = "com.xxl.job.executor.service.jobhandler")
|
||||||
public class XxlJobConfig {
|
public class XxlJobConfig {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${xxl.job.admin.addresses}")
|
||||||
|
private String addresses;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.appname}")
|
||||||
|
private String appname;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.ip}")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.port}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.logpath}")
|
||||||
|
private String logpath;
|
||||||
|
|
||||||
|
|
||||||
|
@Bean(initMethod = "start", destroyMethod = "destroy")
|
||||||
|
public XxlJobExecutor xxlJobExecutor() {
|
||||||
|
logger.error("------------ xxlJobExecutor -----------");
|
||||||
|
XxlJobExecutor xxlJobExecutor = new XxlJobExecutor();
|
||||||
|
xxlJobExecutor.setIp(ip);
|
||||||
|
xxlJobExecutor.setPort(port);
|
||||||
|
xxlJobExecutor.setAppName(appname);
|
||||||
|
xxlJobExecutor.setAdminAddresses(addresses);
|
||||||
|
xxlJobExecutor.setLogPath(logpath);
|
||||||
|
return xxlJobExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ public class IndexController {
|
||||||
@RequestMapping("/")
|
@RequestMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String index() {
|
String index() {
|
||||||
return "xxl job is running.";
|
return "xxl job executor running.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,5 +4,14 @@ server.port=8081
|
||||||
# log config
|
# log config
|
||||||
logging.config=classpath:logback.xml
|
logging.config=classpath:logback.xml
|
||||||
|
|
||||||
|
# xxl-job
|
||||||
|
### 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.executor.appname=xxl-job-executor-example
|
||||||
|
xxl.job.executor.ip=
|
||||||
|
xxl.job.executor.port=9999
|
||||||
|
|
||||||
|
### xxl-job log path
|
||||||
|
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler/
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?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"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
||||||
http://www.springframework.org/schema/context
|
|
||||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
|
||||||
|
|
||||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
|
||||||
<property name="fileEncoding" value="utf-8" />
|
|
||||||
<property name="locations">
|
|
||||||
<list>
|
|
||||||
<value>classpath*:xxl-job-executor.properties</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- ********************************* 基础配置 ********************************* -->
|
|
||||||
|
|
||||||
<!-- 配置01、JobHandler 扫描路径 -->
|
|
||||||
<context:component-scan base-package="com.xxl.job.executor.service.jobhandler" />
|
|
||||||
|
|
||||||
<!-- 配置02、执行器 -->
|
|
||||||
<bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" >
|
|
||||||
<!-- 执行器IP[选填],为空则自动获取 -->
|
|
||||||
<property name="ip" value="${xxl.job.executor.ip}" />
|
|
||||||
<!-- 执行器端口号[必须] -->
|
|
||||||
<property name="port" value="${xxl.job.executor.port}" />
|
|
||||||
<!-- 执行器AppName[选填],为空则关闭自动注册 -->
|
|
||||||
<property name="appName" value="${xxl.job.executor.appname}" />
|
|
||||||
<!-- 执行器注册中心地址[选填],为空则关闭自动注册 -->
|
|
||||||
<property name="adminAddresses" value="${xxl.job.admin.addresses}" />
|
|
||||||
<!-- 执行器日志路径[必填] -->
|
|
||||||
<property name="logPath" value="${xxl.job.executor.logpath}" />
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
|
|
@ -1,10 +0,0 @@
|
||||||
### 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.executor.appname=xxl-job-executor-example
|
|
||||||
xxl.job.executor.ip=
|
|
||||||
xxl.job.executor.port=9999
|
|
||||||
|
|
||||||
### xxl-job log path
|
|
||||||
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler/
|
|
Loading…
Reference in New Issue