Examples of ThreadPoolTaskExecutor


Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    protected TaskExecutor createDefaultTaskExecutor() {
        String pattern = endpoint.getCamelContext().getExecutorServiceManager().getThreadNamePattern();
        String beanName = getBeanName() == null ? endpoint.getThreadName() : getBeanName();

        if (endpoint.getDefaultTaskExecutorType() == DefaultTaskExecutorType.ThreadPool) {
            ThreadPoolTaskExecutor answer = new ThreadPoolTaskExecutor();
            answer.setBeanName(beanName);
            answer.setThreadFactory(new CamelThreadFactory(pattern, beanName, true));
            answer.setCorePoolSize(endpoint.getConcurrentConsumers());
            // Direct hand-off mode. Do not queue up tasks: assign it to a thread immediately.
            // We set no upper-bound on the thread pool (no maxPoolSize) as it's already implicitly constrained by
            // maxConcurrentConsumers on the DMLC itself (i.e. DMLC will only grow up to a level of concurrency as
            // defined by maxConcurrentConsumers).
            answer.setQueueCapacity(0);
            answer.initialize();
            return answer;
        } else {
            SimpleAsyncTaskExecutor answer = new SimpleAsyncTaskExecutor(beanName);
            answer.setThreadFactory(new CamelThreadFactory(pattern, beanName, true));
            return answer;
        }
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        }
        super.tearDown();
    }

    protected TaskExecutor createTaskExecutor() {
        ThreadPoolTaskExecutor exec = new CleanThreadPoolTaskExecutor();
        exec.setWaitForTasksToCompleteOnShutdown(true);
        exec.setQueueCapacity(0);
        exec.afterPropertiesSet();
        return exec;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

      ((ExecutorConfigurationSupport)taskExecutor).shutdown();
    }
  }

  protected static TaskExecutor getDefaultThreadExecutor() {
    ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
    te.setCorePoolSize(5);
    te.setMaxPoolSize(10);
    te.setQueueCapacity(100);
    return te;
  }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    @Override
    @Bean
    public Executor getAsyncExecutor() {
        log.debug("Creating Async Task Executor");
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(propertyResolver.getProperty("corePoolSize", Integer.class, 2));
        executor.setMaxPoolSize(propertyResolver.getProperty("maxPoolSize", Integer.class, 50));
        executor.setQueueCapacity(propertyResolver.getProperty("queueCapacity", Integer.class, 10000));
        executor.setThreadNamePrefix("jhipster-Executor-");
        return new ExceptionHandlingAsyncTaskExecutor(executor);
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

  /**
   * The asynchronous task executor used by the Greenhouse application.
   */
  @Bean
  public Executor taskExecutor() {
    return new ThreadPoolTaskExecutor();
  }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

*/
public class WampConfigurerAdapter implements WampConfigurer {

  @Override
  public Executor outboundExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setThreadNamePrefix("WampOutbound-");
    executor.initialize();
    return executor;
  }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    public void testConcurrentConsumersWithReply() throws Exception {
        // latch for the 5 exchanges we expect
        final CountDownLatch latch = new CountDownLatch(5);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int count = i;
            executor.execute(new Runnable() {
                public void run() {
                    // request body is InOut pattern and thus we expect a reply (JMSReply)
                    Object response = template.requestBody("activemq:a", "World #" + count);
                    assertEquals("Bye World #" + count, response);
                    latch.countDown();
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        }
        return map;
    }

    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setThreadNamePrefix("MyExecutor-");
        executor.initialize();
        return executor;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    private static final int MAX_POOL_SIZE = 42;
    private static final int QUEUE_CAPACITY = 11;

    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(CORE_POOL_SIZE);
        executor.setMaxPoolSize(MAX_POOL_SIZE);
        executor.setQueueCapacity(QUEUE_CAPACITY);
        executor.setThreadNamePrefix("MyExecutor-");
        executor.initialize();
        return executor;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * 200;
                    for (int i = 0; i < 200; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.