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

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

Introduction

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

Prototype

public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown) 

Source Link

Document

Set whether to wait for scheduled tasks to complete on shutdown, not interrupting running tasks and executing all tasks in the queue.

Usage

From source file:org.apache.servicemix.jbi.cluster.engine.AbstractClusterEndpointTest.java

protected TaskExecutor createTaskExecutor() {
    ThreadPoolTaskExecutor exec = new CleanThreadPoolTaskExecutor();
    exec.setWaitForTasksToCompleteOnShutdown(true);
    exec.setQueueCapacity(0);/*from   w w  w . j a v  a  2s.  c  o m*/
    exec.afterPropertiesSet();
    return exec;
}

From source file:com.ethlo.geodata.GeodataServiceImpl.java

public void load() {
    ensureBaseDirectory();/*from   w ww.ja  v  a2  s.  c  o  m*/

    final SourceDataInfoSet sourceInfo = geoMetaService.getSourceDataInfo();
    if (sourceInfo.isEmpty()) {
        logger.error(
                "Cannot start geodata server as there is no data. Please run with 'update' parameter to import data");
        System.exit(1);
    }

    loadHierarchy();

    final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(3);
    taskExecutor.setThreadNamePrefix("data-loading-");
    taskExecutor.initialize();

    taskExecutor.execute(this::loadLocations);
    taskExecutor.execute(this::loadMbr);
    taskExecutor.execute(this::loadIps);

    taskExecutor.setAwaitTerminationSeconds(Integer.MAX_VALUE);
    taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
    taskExecutor.shutdown();

    //final ResultSet<GeoLocation> result = geoNamesRepository.retrieve(QueryFactory.equal(CqGeonamesRepository.ATTRIBUTE_FEATURE_CODE, "ADM1"));
    //result.forEach(this::connectAdm1WithCountry);

    publisher.publishEvent(new DataLoadedEvent(this, DataType.ALL, Operation.LOAD, 1, 1));
}