Java Code Examples for org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#setBeanName()

The following examples show how to use org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#setBeanName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadUtils.java    From rqueue with Apache License 2.0 5 votes vote down vote up
public static ThreadPoolTaskExecutor createTaskExecutor(
    String beanName, String threadPrefix, int corePoolSize, int maxPoolSize) {
  ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
  threadPoolTaskExecutor.setThreadNamePrefix(threadPrefix);
  threadPoolTaskExecutor.setBeanName(beanName);
  if (corePoolSize > 0) {
    threadPoolTaskExecutor.setCorePoolSize(corePoolSize);
    threadPoolTaskExecutor.setMaxPoolSize(Math.max(corePoolSize, maxPoolSize));
    threadPoolTaskExecutor.setQueueCapacity(0);
    threadPoolTaskExecutor.afterPropertiesSet();
  }
  return threadPoolTaskExecutor;
}
 
Example 2
Source File: AsyncConfig.java    From mojito with Apache License 2.0 5 votes vote down vote up
/**
 * When using aspectJ + @EnableAsync, there is no default executor. Need to
 * create one.
 *
 * @return
 */
@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setBeanName("asyncExecutor");
    threadPoolTaskExecutor.setCorePoolSize(5);
    threadPoolTaskExecutor.setMaxPoolSize(10);
    threadPoolTaskExecutor.initialize();
    return threadPoolTaskExecutor;
}
 
Example 3
Source File: AsyncConfig.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "pollableTaskExecutor")
public AsyncTaskExecutor getPollableTaskExecutor() {
    ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setBeanName("pollableTask");
    threadPoolTaskExecutor.setCorePoolSize(5);
    threadPoolTaskExecutor.setMaxPoolSize(30);
    threadPoolTaskExecutor.initialize();

    return new DelegatingSecurityContextAsyncTaskExecutor(threadPoolTaskExecutor);
}