Example usage for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setMaxPoolSize

List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setMaxPoolSize

Introduction

In this page you can find the example usage for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setMaxPoolSize.

Prototype

public void setMaxPoolSize(int maxPoolSize) 

Source Link

Document

Set the ThreadPoolExecutor's maximum pool size.

Usage

From source file:org.schedoscope.metascope.config.TaskConfiguration.java

@Bean
public TaskExecutor asyncTaskExecutor() {
    ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(10);
    threadPoolTaskExecutor.setMaxPoolSize(10);
    threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
    return threadPoolTaskExecutor;
}

From source file:dk.clanie.actor.ActorAnnotationBeanPostProcessor.java

public Object postProcessAfterInitialization(Object bean, String beanName) {
    if (bean instanceof AopInfrastructureBean) {
        // Ignore AOP infrastructure such as scoped proxies.
        return bean;
    }// www.  j  a  v a 2 s.  c o  m
    Class<?> targetClass = AopUtils.getTargetClass(bean);
    Actor annotation = AnnotationUtils.findAnnotation(targetClass, Actor.class);
    if (annotation != null) {
        //      if (AopUtils.canApply(this.asyncAnnotationAdvisor, targetClass)) {

        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setMaxPoolSize(1);
        executor.setDaemon(true);
        String threadNamePrefix = beanName + ",";
        executor.setThreadNamePrefix(threadNamePrefix);
        executor.initialize();

        ActorAnnotationAdvisor actorAnnotationAdvisor = new ActorAnnotationAdvisor(executor);

        if (bean instanceof Advised) {
            ((Advised) bean).addAdvisor(0, actorAnnotationAdvisor);
            return bean;
        } else {
            ProxyFactory proxyFactory = new ProxyFactory(bean);
            // Copy our properties (proxyTargetClass etc) inherited from ProxyConfig.
            proxyFactory.copyFrom(this);
            proxyFactory.addAdvisor(actorAnnotationAdvisor);
            return proxyFactory.getProxy(this.beanClassLoader);
        }
    } else {
        // No async proxy needed.
        return bean;
    }
}

From source file:org.apache.nutch.storage.local.SpringConfiguration.java

@Override
public Executor getAsyncExecutor() {
    // TODO move magic numbers to properties file
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(7);//from w ww.  ja  v  a  2 s .  co m
    executor.setMaxPoolSize(42);
    executor.setQueueCapacity(11);
    executor.setThreadNamePrefix("SpringExecutor-");
    executor.initialize();
    return executor;
}

From source file:com.sample.config.AsyncConfig.java

@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(2); // seems like too many thread here will make gmail return error
    executor.setMaxPoolSize(2);
    executor.setQueueCapacity(3000);/* w w  w.j  a v a2s.c  o m*/
    executor.setThreadNamePrefix("EmailExecutor-");
    executor.initialize();
    return executor;
}

From source file:com.epam.ta.reportportal.core.configs.JobsConfiguration.java

@Bean(name = "autoAnalyzeTaskExecutor")
public TaskExecutor autoAnalyzeTaskExecutor() {
    final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setCorePoolSize(10);
    threadPoolTaskExecutor.setMaxPoolSize(30);
    threadPoolTaskExecutor.setQueueCapacity(200);
    threadPoolTaskExecutor.setAllowCoreThreadTimeOut(true);
    threadPoolTaskExecutor.setThreadNamePrefix("auto-analyze-exec");
    return threadPoolTaskExecutor;
}

From source file:org.elasticsoftware.elasticactors.examples.springweb.config.ApplicationContextConfiguration.java

@Bean(name = "asyncExecutor")
public java.util.concurrent.Executor getAsyncExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(Runtime.getRuntime().availableProcessors());
    executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors() * 3);
    executor.setQueueCapacity(1024);//from   w  w  w  .j av  a  2 s.c  om
    executor.setThreadNamePrefix("ASYNCHRONOUS-ANNOTATION-EXECUTOR-");
    executor.initialize();
    return executor;
}

From source file:org.kew.rmf.reconciliation.config.MvcConfig.java

/**
 * TaskExecutor for asynchronous pooled tasks
 *//*from   ww  w .j  av  a2s.  c  o  m*/
@Bean
public TaskExecutor taskExecutor() {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(2);
    taskExecutor.setMaxPoolSize(2);
    taskExecutor.initialize();
    return taskExecutor;
}

From source file:com.cfitzarl.cfjwed.core.config.WebApplicationMvcConfigurer.java

@Bean(name = "emailTaskExecutor")
public ThreadPoolTaskExecutor emailTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(1);/*from   w  w  w . ja  v a2 s  . co  m*/
    executor.setMaxPoolSize(5);
    return executor;
}

From source file:com.axel.config.ServiceConfig.java

@Override
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    // to customize with your requirements
    executor.setCorePoolSize(5);// w w  w  .  ja  v a 2s .c o m
    executor.setMaxPoolSize(40);
    executor.setQueueCapacity(100);
    executor.setThreadNamePrefix("MyExecutor-");
    executor.initialize();
    return executor;
}

From source file:org.bremersee.common.spring.autoconfigure.SchedulingAutoConfiguration.java

@Bean(name = { "taskExecutor", "metricsExecutor" })
@Primary/* w w  w .  j  a v  a 2s.  c  o  m*/
public Executor taskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(properties.getTaskExecutorCorePoolSize());
    executor.setMaxPoolSize(properties.getTaskExecutorMaxPoolSize());
    executor.setQueueCapacity(properties.getTaskExecutorQueueCapacity());
    executor.setThreadNamePrefix(properties.getTaskExecutorThreadNamePrefix());
    executor.initialize();
    return executor;
}