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

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

Introduction

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

Prototype

ThreadPoolTaskExecutor

Source Link

Usage

From source file:com.apress.prospringintegration.concurrency.taskexecutorexample.TaskExecutorExampleConfiguration.java

@Bean
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(50);//  w w w. j av a2  s.  c o m
    executor.setDaemon(false);
    executor.setWaitForTasksToCompleteOnShutdown(true);
    executor.setMaxPoolSize(100);
    executor.setAllowCoreThreadTimeOut(true);
    return executor;
}

From source file:org.cloudfoundry.caldecott.client.TunnelServer.java

protected static TaskExecutor getDefaultThreadExecutor() {
    ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
    te.setCorePoolSize(5);//  w w  w  .jav  a 2  s .  co m
    te.setMaxPoolSize(10);
    te.setQueueCapacity(100);
    return te;
}

From source file:com.github.woonsan.jackrabbit.migration.datastore.batch.BatchConfiguration.java

@Bean
public TaskExecutor taskExecutor() {
    final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(getMinWorkers());
    taskExecutor.setMaxPoolSize(getMaxWorkers());
    taskExecutor.setDaemon(true);//from   ww  w  . j  a v  a  2 s  .c  o  m
    return taskExecutor;
}

From source file:com.netflix.genie.web.configs.TaskConfig.java

/**
 * Get a task executor for executing tasks asynchronously that don't need to be scheduled at a recurring rate.
 *
 * @param poolSize The number of threads desired for this system. Likely best to do one more than number of CPUs
 * @return The task executor the system to use
 *///from   w ww . j  a v a 2  s  .c o  m
@Bean
public AsyncTaskExecutor taskExecutor(@Value("${genie.tasks.executor.pool.size:1}") final int poolSize) {
    final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(poolSize);
    return executor;
}

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

@Bean(name = { "taskExecutor", "metricsExecutor" })
@Primary// ww  w .ja va 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;
}

From source file:eu.tripledframework.eventbus.autoconfigure.EventBusAutoConfiguration.java

private Executor taskExecutor() {
    ThreadPoolTaskExecutor executorService = new ThreadPoolTaskExecutor();
    executorService.setCorePoolSize(5);/*  w  w  w  . ja v  a  2s  .  c  o  m*/
    executorService.setMaxPoolSize(10);

    executorService.afterPropertiesSet();
    return executorService;
}

From source file:com.codeveo.lago.bot.stomp.client.AbstractHttpLagoBot.java

protected AbstractHttpLagoBot() {
    objectMapper = new ObjectMapper();
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    /* jaxb only */
    JaxbAnnotationModule module = new JaxbAnnotationModule();
    objectMapper.registerModule(module);

    taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setMaxPoolSize(THREAD_POOL_SIZE);
    taskExecutor.initialize();//from ww  w .  j  av a 2 s . c om

    WebSocketContainer webSocketContainer = ContainerProvider.getWebSocketContainer();
    webSocketContainer.setDefaultMaxSessionIdleTimeout(CLIENT_MAX_IDLE_TIMEOUT);

    webSocketClient = new StandardWebSocketClient(webSocketContainer);
    webSocketClient.setTaskExecutor(taskExecutor);
}

From source file:com.ciphertool.zodiacengine.genetic.algorithms.BasicGeneticAlgorithmTest.java

@BeforeClass
public static void setUp() {
    FitnessEvaluator fitnessEvaluator = new CipherSolutionKnownSolutionFitnessEvaluator();
    fitnessEvaluator.setGeneticStructure(zodiac408);

    CrossoverAlgorithm crossoverAlgorithm = new LowestCommonGroupCrossoverAlgorithm();
    crossoverAlgorithm.setFitnessEvaluator(fitnessEvaluator);

    SingleSequenceMutationAlgorithm mutationAlgorithm = new SingleSequenceMutationAlgorithm();
    mutationAlgorithm.setSequenceDao(new PlaintextSequenceDao());

    ProbabilisticSelectionAlgorithm selectionAlgorithm = new ProbabilisticSelectionAlgorithm();

    Selector selector = new RouletteSelector();

    GeneticAlgorithmStrategy geneticAlgorithmStrategy = new GeneticAlgorithmStrategy(zodiac408, POPULATION_SIZE,
            LIFESPAN, MAX_GENERATIONS, SURVIVAL_RATE, MUTATION_RATE, MAX_MUTATIONS_PER_INDIVIDUAL,
            CROSSOVER_RATE, MUTATE_DURING_CROSSOVER, fitnessEvaluator, crossoverAlgorithm, mutationAlgorithm,
            selectionAlgorithm, selector);

    population.setBreeder(solutionBreederMock);
    population.setSelector(selector);// w w  w .j av a 2s.com

    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(MAX_THREADS);
    taskExecutor.setMaxPoolSize(MAX_THREADS);
    taskExecutor.setQueueCapacity(THREAD_EXECUTOR_QUEUE_CAPACITY);
    taskExecutor.setKeepAliveSeconds(1);
    taskExecutor.setAllowCoreThreadTimeOut(true);
    taskExecutor.initialize();

    population.setTaskExecutor(taskExecutor);

    geneticAlgorithm = new BasicGeneticAlgorithm();
    geneticAlgorithm.setPopulation(population);
    geneticAlgorithm.setStrategy(geneticAlgorithmStrategy);

    ExecutionStatisticsDao executionStatisticsDaoMock = mock(ExecutionStatisticsDao.class);
    ((BasicGeneticAlgorithm) geneticAlgorithm).setExecutionStatisticsDao(executionStatisticsDaoMock);
}

From source file:com.bt.aloha.media.convedia.conference.MaxConferenceDurationTerminationTest.java

@Test
public void testInitializeWithTermination() {
    //setup/*from w w w.j  a v  a  2 s.c  o m*/
    conferenceCollection.add(conferenceInfoInPast);
    maxConferenceDurationTermination.setConferenceCollection(conferenceCollection);
    ConferenceBean conferenceBean = EasyMock.createMock(ConferenceBean.class);
    conferenceBean.endConference(conferenceInfoInPast.getId(),
            ConferenceTerminationCause.MaximumDurationExceeded);
    EasyMock.replay(conferenceBean);
    maxConferenceDurationTermination.setConferenceBean(conferenceBean);
    ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
    te.initialize();
    maxConferenceDurationTermination.setTaskExecutor(te);

    //act
    maxConferenceDurationTermination.runTask();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
        e.printStackTrace();
    } // allow time for thread to run

    //assert
    EasyMock.verify(conferenceBean);
}

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 . c  o  m
    executor.setMaxPoolSize(5);
    return executor;
}