List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setThreadNamePrefix
@Override public void setThreadNamePrefix(@Nullable String threadNamePrefix)
From source file:org.homiefund.config.ApplicationConfiguration.java
@Override public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(4);/*from w w w . ja va 2 s. co m*/ executor.setMaxPoolSize(42); executor.setQueueCapacity(12); executor.setThreadNamePrefix("HomieExecutor-"); executor.initialize(); return executor; }
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; }//from w w w .j a v a2 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:kymr.github.io.future.FutureSpringApplication.java
@Bean ThreadPoolTaskExecutor tp() {//from w ww . ja v a2 s .c o m ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.setCorePoolSize(10); // default core thread pool te.setQueueCapacity(200); te.setMaxPoolSize(100); // after core pool is full -> after queue capacity (generally, unlimited) is full -> then, max pool size works. te.setThreadNamePrefix("mythread"); te.initialize(); //te.setAllowCoreThreadTimeOut(); //te.getKeepAliveSeconds() //te.setTaskDecorator(); // for task monitoring return te; }
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);/* w w w . ja va2s . co m*/ executor.setThreadNamePrefix("ASYNCHRONOUS-ANNOTATION-EXECUTOR-"); executor.initialize(); return executor; }
From source file:nl.pinniq.web.config.WebMvcConfiguration.java
@Bean public ThreadPoolTaskExecutor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(5);/*from w ww.java 2 s . c o m*/ executor.setBeanName("threadPoolTaskExecutor"); executor.setMaxPoolSize(50); executor.setQueueCapacity(10); executor.setThreadNamePrefix("MyExecutor-"); executor.initialize(); return executor; }
From source file:org.obiba.mica.config.AsyncConfiguration.java
@Override @Bean// www . jav a 2s .c o m public Executor getAsyncExecutor() { Integer poolSize = propertyResolver.getProperty("poolSize", Integer.class, DEFAULT_POOL_SIZE); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(poolSize); executor.setMaxPoolSize(poolSize); executor.setQueueCapacity( propertyResolver.getProperty("queueCapacity", Integer.class, DEFAULT_QUEUE_CAPACITY)); executor.setThreadNamePrefix("mica-executor-"); return new ExceptionHandlingAsyncTaskExecutor(executor); }
From source file:org.obiba.mica.config.AsyncConfiguration.java
@Bean(name = "opalExecutor") public Executor getOpalAsyncExecutor() { log.debug("Creating Async Task Executor"); Integer poolSize = propertyResolver.getProperty("opal.poolSize", Integer.class, DEFAULT_POOL_SIZE); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(poolSize);//from ww w . ja va2 s . c o m executor.setMaxPoolSize(poolSize); executor.setQueueCapacity( propertyResolver.getProperty("opal.queueCapacity", Integer.class, DEFAULT_QUEUE_CAPACITY)); executor.setThreadNamePrefix("mica-opal-executor-"); return new ExceptionHandlingAsyncTaskExecutor(executor); }
From source file:com.netflix.genie.web.configs.GenieTasksAutoConfiguration.java
/** * Get a task executor for executing tasks asynchronously that don't need to be scheduled at a recurring rate. * * @param tasksExecutorPoolProperties The properties for the task executor thread pool * @return The task executor the system to use */// ww w . ja v a 2 s . c o m @Bean @ConditionalOnMissingBean(name = "genieAsyncTaskExecutor") public AsyncTaskExecutor genieAsyncTaskExecutor(final TasksExecutorPoolProperties tasksExecutorPoolProperties) { final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(tasksExecutorPoolProperties.getSize()); executor.setThreadNamePrefix(tasksExecutorPoolProperties.getThreadNamePrefix()); return executor; }
From source file:org.bremersee.common.spring.autoconfigure.SchedulingAutoConfiguration.java
@Bean(name = { "taskExecutor", "metricsExecutor" }) @Primary//from ww w.j av a2 s . 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; }
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; }