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

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

Introduction

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

Prototype

@Override
public void afterPropertiesSet() 

Source Link

Document

Calls initialize() after the container applied all property values.

Usage

From source file:org.springframework.batch.core.test.step.MapRepositoryFaultTolerantStepFactoryBeanTests.java

@Before
public void setUp() throws Exception {

    reader = new SkipReaderStub();
    writer = new SkipWriterStub();
    processor = new SkipProcessorStub();

    factory = new FaultTolerantStepFactoryBean<String, String>();

    factory.setBeanName("stepName");
    factory.setTransactionManager(transactionManager);
    factory.setCommitInterval(3);//  w  w  w.ja  v a  2 s.c  om
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(3);
    taskExecutor.setMaxPoolSize(6);
    taskExecutor.setQueueCapacity(0);
    taskExecutor.afterPropertiesSet();
    factory.setTaskExecutor(taskExecutor);

}

From source file:org.springframework.batch.repeat.support.TaskExecutorRepeatTemplateBulkAsynchronousTests.java

@Test
public void testThrottleLimitEarlyFinishThreadStarvation() throws Exception {

    early = 2;//  w  w w  .  j  a v a2  s  .c o m
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    // Set the concurrency limit below the throttle limit for possible
    // starvation condition
    taskExecutor.setMaxPoolSize(20);
    taskExecutor.setCorePoolSize(10);
    taskExecutor.setQueueCapacity(0);
    // This is the most sensible setting, otherwise the bookkeeping in
    // ResultHolderResultQueue gets out of whack when tasks are aborted.
    taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    taskExecutor.afterPropertiesSet();
    template.setTaskExecutor(taskExecutor);

    template.iterate(callback);
    int frequency = Collections.frequency(items, "null");
    // System.err.println("Frequency: " + frequency);
    // System.err.println("Items: " + items);
    // Extra tasks will be submitted before the termination is detected
    assertEquals(total, items.size() - frequency);
    assertTrue(frequency <= throttleLimit + 1);

    taskExecutor.destroy();

}

From source file:org.springframework.statemachine.recipes.tasks.TasksHandler.java

private static TaskExecutor taskExecutor(int taskCount) {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.afterPropertiesSet();
    taskExecutor.setCorePoolSize(taskCount);
    return taskExecutor;
}