package com.nokia.sms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class BeanConfig {

    @Bean("socketScheduler")
    public ThreadPoolTaskScheduler socketScheduler() {
        // 使用最常用的ThreadPoolTaskScheduler
        ThreadPoolTaskScheduler socketScheduler = new ThreadPoolTaskScheduler();
        // 线程数
        socketScheduler.setPoolSize(1);
        socketScheduler.setRemoveOnCancelPolicy(true);
        socketScheduler.setThreadNamePrefix("socketScheduler-");
        log.info("已完成 用于socket调度的 ThreadPoolTaskScheduler 配置, poolSize = {}", 1);
        return socketScheduler;
    }
}
