Search in sources :

Example 81 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project open-smart-grid-platform by OSGP.

the class LightSwitchingOnConfig method lightSwitchingOnTaskScheduler.

@Bean(destroyMethod = "shutdown")
public TaskScheduler lightSwitchingOnTaskScheduler() {
    final ThreadPoolTaskScheduler lightSwitchingOnTaskScheduler = new ThreadPoolTaskScheduler();
    lightSwitchingOnTaskScheduler.setPoolSize(Integer.parseInt(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_LIGHTSWITCHING_ON_POOL_SIZE)));
    lightSwitchingOnTaskScheduler.setThreadNamePrefix(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_LIGHTSWITCHING_ON_THREAD_NAME_PREFIX));
    lightSwitchingOnTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
    return lightSwitchingOnTaskScheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Bean(org.springframework.context.annotation.Bean)

Example 82 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project open-smart-grid-platform by OSGP.

the class TariffSwitchingHighConfig method tariffSwitchingHighTaskScheduler.

@Bean(destroyMethod = "shutdown")
public TaskScheduler tariffSwitchingHighTaskScheduler() {
    final ThreadPoolTaskScheduler tariffSwitchingHighTaskScheduler = new ThreadPoolTaskScheduler();
    tariffSwitchingHighTaskScheduler.setPoolSize(Integer.parseInt(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_TARIFFSWITCHING_HIGH_POOL_SIZE)));
    tariffSwitchingHighTaskScheduler.setThreadNamePrefix(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_TARIFFSWITCHING_HIGH_THREAD_NAME_PREFIX));
    tariffSwitchingHighTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
    return tariffSwitchingHighTaskScheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Bean(org.springframework.context.annotation.Bean)

Example 83 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project open-smart-grid-platform by OSGP.

the class AutonomousDeviceRebootConfig method deviceRebootTaskScheduler.

@Bean(destroyMethod = "shutdown")
public TaskScheduler deviceRebootTaskScheduler() {
    final ThreadPoolTaskScheduler deviceRebootTaskScheduler = new ThreadPoolTaskScheduler();
    deviceRebootTaskScheduler.setPoolSize(Integer.parseInt(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_DEVICE_REBOOT_POOL_SIZE)));
    deviceRebootTaskScheduler.setThreadNamePrefix(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_DEVICE_REBOOT_THREAD_NAME_PREFIX));
    deviceRebootTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
    return deviceRebootTaskScheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Bean(org.springframework.context.annotation.Bean)

Example 84 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project open-smart-grid-platform by OSGP.

the class Iec60870AsduGeneratorService method getThreadPoolTaskScheduler.

private ThreadPoolTaskScheduler getThreadPoolTaskScheduler() {
    final ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
    threadPoolTaskScheduler.setPoolSize(1);
    threadPoolTaskScheduler.setThreadNamePrefix("ThreadPoolTaskScheduler");
    threadPoolTaskScheduler.initialize();
    return threadPoolTaskScheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)

Example 85 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project fast_responder by Silwings-git.

the class ResponderWebConfigurer method httpTaskScheduler.

@Bean("httpTaskScheduler")
public TaskScheduler httpTaskScheduler(final TaskSchedulerProperties taskSchedulerProperties) {
    final ThreadPoolTaskScheduler httpTaskScheduler = new ThreadPoolTaskScheduler();
    // 因为该服务通常用于调试,http任务不会很多,默认设置核心线程数为1
    httpTaskScheduler.setPoolSize(taskSchedulerProperties.getThreadPoolSize());
    return httpTaskScheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Bean(org.springframework.context.annotation.Bean)

Aggregations

ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)259 Bean (org.springframework.context.annotation.Bean)117 Test (org.junit.jupiter.api.Test)73 BeanFactory (org.springframework.beans.factory.BeanFactory)33 CountDownLatch (java.util.concurrent.CountDownLatch)24 QueueChannel (org.springframework.integration.channel.QueueChannel)23 AtomicReference (java.util.concurrent.atomic.AtomicReference)18 Test (org.junit.Test)18 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)18 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)15 GenericMessage (org.springframework.messaging.support.GenericMessage)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 ExecutorService (java.util.concurrent.ExecutorService)12 ArrayList (java.util.ArrayList)11 Message (org.springframework.messaging.Message)9 MessageChannel (org.springframework.messaging.MessageChannel)9 LogAccessor (org.springframework.core.log.LogAccessor)8 MessagingException (org.springframework.messaging.MessagingException)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 IOException (java.io.IOException)6