All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cjy.fat.config.TransactionThreadPoolConfig Maven / Gradle / Ivy

There is a newer version: 1.0.6-RELEASE
Show newest version
package com.cjy.fat.config;

import java.util.concurrent.ThreadPoolExecutor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
public class TransactionThreadPoolConfig {
	
	@Value("${fb.thread.core_pool_size:20}")
	private int corePoolSize ;
	
	@Value("${fb.thread.max_pool_size:50}")
	private int maxPoolSize ;
	
	@Value("${fb.thread.queue_capacity:200}")
	private int queueCapacity ;
	
	@Value("${fb.thread.keep_alive_seconds:60}")
	private int keepAliveSeconds;

	@Bean
	public AsyncTaskExecutor transactionResolveExecutor() {
		 ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(corePoolSize);//初始化线程数
         executor.setMaxPoolSize(maxPoolSize);//最大线程数量
         executor.setQueueCapacity(queueCapacity);//缓冲数量
         executor.setKeepAliveSeconds(keepAliveSeconds);//60秒内该线程未被执行自动销毁
         executor.setThreadNamePrefix("fat_resolve-");
         executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
         executor.initialize();
         return executor;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy