package com.iailab.module.system.job.demo;
|
|
import com.iailab.framework.tenant.core.job.TenantJob;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
@Component
|
public class DemoJob {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private final AtomicInteger counts = new AtomicInteger();
|
|
private static final Object lock = new Object();
|
|
|
@XxlJob("demoJob")
|
@TenantJob
|
public void execute() {
|
synchronized (lock) {
|
logger.info("[execute][定时第 ({}) 次执行]", counts.incrementAndGet());
|
System.out.println(new Date() + ": 我是系统定时任务");
|
}
|
}
|
|
}
|