package cn.axzo.msg.center.nimpush;

import com.taobao.api.internal.util.NamedThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author yanglin
 */
@Configuration
public class PushExecutorConfig {

    public static final String PUSH_EXECUTOR = "pushExecutor";

    @Bean(PUSH_EXECUTOR)
    public ExecutorService pushExecutor() {
        return new ThreadPoolExecutor(
                30, 50,
                10, TimeUnit.MINUTES,
                new ArrayBlockingQueue<>(10000),
                new NamedThreadFactory(getClass().getSimpleName()));
    }

}
