package com.yc.ship.module.trade.framework.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * &#064;Description ：异步任务线程池配置
 * &#064;Author ：qsl
 * &#064;Date ：2025/12/21 16:28
 */
@Configuration
@EnableAsync
public class AsyncConfiguration implements AsyncConfigurer {

    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);
        executor.setMaxPoolSize(30);
//        executor.setQueueCapacity(1000);//不设置，默认最大
        executor.setThreadNamePrefix("Async-");
        executor.initialize();
        return executor;
    }
}
