List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setWaitForTasksToCompleteOnShutdown
public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
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)); }