package com.example.demo.config;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

/**
 * 轮询查询配置类
 * 确保每2分钟精确执行轮询查询任务
 */
@Configuration
@EnableScheduling
public class PollingConfig implements SchedulingConfigurer {

    @Override
    public void configureTasks(@NonNull ScheduledTaskRegistrar taskRegistrar) {
        // 使用自定义线程池执行定时任务（支持100-200人并发）
        ScheduledExecutorService executor = Executors.newScheduledThreadPool(10);
        taskRegistrar.setScheduler(executor);
    }
}
