提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.job.demo; |
H |
2 |
|
|
3 |
import com.iailab.framework.tenant.core.job.TenantJob; |
|
4 |
import com.xxl.job.core.handler.annotation.XxlJob; |
|
5 |
import org.slf4j.Logger; |
|
6 |
import org.slf4j.LoggerFactory; |
|
7 |
import org.springframework.stereotype.Component; |
|
8 |
|
|
9 |
import java.util.Date; |
|
10 |
import java.util.concurrent.atomic.AtomicInteger; |
|
11 |
|
|
12 |
@Component |
|
13 |
public class DemoJob { |
|
14 |
|
|
15 |
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
16 |
|
|
17 |
private final AtomicInteger counts = new AtomicInteger(); |
|
18 |
|
|
19 |
private static final Object lock = new Object(); |
|
20 |
|
|
21 |
|
|
22 |
@XxlJob("demoJob") |
|
23 |
@TenantJob |
|
24 |
public void execute() { |
|
25 |
synchronized (lock) { |
|
26 |
logger.info("[execute][定时第 ({}) 次执行]", counts.incrementAndGet()); |
|
27 |
System.out.println(new Date() + ": 我是系统定时任务"); |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
} |