【采集调度器-后端TCP API】采集调度器下发任务命令 API

segment2.0
linrf 2 years ago
parent 490d8bbbc1
commit 6acba2661e

@ -1,12 +1,11 @@
package com.docus.server; package com.docus.server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
@EnableAsync
@Slf4j
@EnableFeignClients(basePackages = ("com.docus.core.excel.feign")) @EnableFeignClients(basePackages = ("com.docus.core.excel.feign"))
@SpringBootApplication(scanBasePackages = {"com.docus"}) @SpringBootApplication(scanBasePackages = {"com.docus"})
public class AppRunBootstrap { public class AppRunBootstrap {

@ -9,26 +9,19 @@ import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@Configuration //@Configuration
@EnableScheduling
@EnableAsync
public class JobConfig { public class JobConfig {
@Resource @Resource
private ChannelRepository channelRepository; private ChannelRepository channelRepository;
@Async // @Async("recordMessage")
@Scheduled(cron = "0/1 * * * * ?") // @Scheduled(cron = "0/1 * * * * ?")
public void runTask() throws InterruptedException { public void runTask() throws InterruptedException {
Map<String, Channel> channelMap = channelRepository.getIpToChannelCacheMap(); Map<String, Channel> channelMap = channelRepository.getIpToChannelCacheMap();

@ -0,0 +1,25 @@
package com.docus.server.common;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class SchedulerTask {
//定时任务
// 5 * * * * ? 在每分钟的5秒执行
@Scheduled(cron = "0/1 * * * * ?")
public void scheduleTask() {
try {
log.info("定时任务: 开始执行");
//todo:执行业务
log.info("定时任务: 执行完毕");
} catch (Exception e) {
log.error("定时任务执行出错", e);
}
}
}
Loading…
Cancel
Save