feat:
- 添加task配置和定时任务
This commit is contained in:
parent
7fa1a38e33
commit
93c2e74571
@ -0,0 +1,31 @@
|
||||
package asia.yulinling.workflow.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.SchedulingTaskExecutor;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 定时任务配置类
|
||||
* </p>
|
||||
*
|
||||
* @author YLL
|
||||
* @since 2025/6/20
|
||||
*/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class SchedulingConfig {
|
||||
|
||||
@Bean
|
||||
public SchedulingTaskExecutor schedulingTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setThreadNamePrefix("WorkflowTaskScheduler-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package asia.yulinling.workflow.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
/**
|
||||
* <p>
|
||||
* 定时任务
|
||||
* </p>
|
||||
*
|
||||
* @author YLL
|
||||
* @since 2025/6/20
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ScheduledTask {
|
||||
@Scheduled(fixedRate = 1000)
|
||||
public void runEvery1SSecond() {
|
||||
// log.info("执行定时任务 1s");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user