调度中心配置
This commit is contained in:
parent
c877a14bd6
commit
7ede50975a
@ -1,16 +1,31 @@
|
||||
package cn.iocoder.yudao.module.system.job.demo;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.context.XxlJobContext;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DemoJob {
|
||||
|
||||
@XxlJob("demoJob")
|
||||
@TenantJob
|
||||
public void execute() {
|
||||
System.out.println("美滋滋");
|
||||
private final AtomicInteger counts = new AtomicInteger();
|
||||
|
||||
@XxlJob("testJob")
|
||||
//@TenantJob --- ⚠️ 这个注解 会将租户列表拉出来 完了后逐个租户执行 定时任务需要注意
|
||||
public ReturnT<String> execute() throws Exception {
|
||||
//获取参数
|
||||
XxlJobContext xxlJobContext = XxlJobContext.getXxlJobContext();
|
||||
String jobParam = xxlJobContext.getJobParam();
|
||||
System.out.println(jobParam);
|
||||
// 打印日志
|
||||
log.info("[execute][定时第 ({}) 次执行]", counts.incrementAndGet());
|
||||
// 返回执行成功
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,7 +81,13 @@ xxl:
|
||||
enabled: false # 是否开启调度中心,默认为 true 开启
|
||||
admin:
|
||||
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
|
||||
|
||||
executor:
|
||||
appname: ${spring.application.name} # 执行器 AppName
|
||||
ip: # 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
|
||||
port: 6666 # ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口;
|
||||
logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 # 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;
|
||||
#accessToken: default_token
|
||||
logretentiondays: 30 # 执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能;
|
||||
--- #################### 服务保障相关配置 ####################
|
||||
|
||||
# Lock4j 配置项
|
||||
|
Loading…
Reference in New Issue
Block a user