You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
package com.mh.user.job; |
|
|
|
import com.mh.user.netty.NettyMeterClient; |
|
import com.mh.user.constants.SocketMessage; |
|
import lombok.SneakyThrows; |
|
import lombok.extern.slf4j.Slf4j; |
|
import org.quartz.DisallowConcurrentExecution; |
|
import org.quartz.Job; |
|
import org.quartz.JobExecutionContext; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
/** |
|
* @author ljf |
|
* @title : |
|
* @description : 定时采集电表数据任务 |
|
* @updateTime 2020-05-18 |
|
* @throws : |
|
*/ |
|
/** |
|
* :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行. |
|
* :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效 |
|
* :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行, |
|
* 否则会在3秒时再启用新的线程执行 |
|
*/ |
|
@DisallowConcurrentExecution |
|
@Slf4j |
|
public class JobMeter implements Job { |
|
|
|
@Autowired |
|
private SocketMessage socketMessage; |
|
|
|
@SneakyThrows |
|
@Override |
|
public void execute(JobExecutionContext jobExecutionContext) { |
|
log.info("定时采集电表数据任务开始"); |
|
NettyMeterClient nettyMeterClient = new NettyMeterClient(); |
|
nettyMeterClient.connect(socketMessage.getPort(), socketMessage.getIP()); |
|
} |
|
}
|
|
|