Commit 4cd338e9 authored by ipatini's avatar ipatini
Browse files

EMS: Control Service: Added 'ControlServiceProperties.TaskSchedulerProperties'...

EMS: Control Service: Added 'ControlServiceProperties.TaskSchedulerProperties' inner class, and moved TaskSchedulerConfig settings into it.
parent 9c5f9878
...@@ -74,4 +74,12 @@ public class ControlServiceProperties { ...@@ -74,4 +74,12 @@ public class ControlServiceProperties {
// control.ssl.** settings // control.ssl.** settings
private KeystoreAndCertificateProperties ssl; private KeystoreAndCertificateProperties ssl;
private TaskSchedulerProperties taskScheduler = new TaskSchedulerProperties();
@Data
public static class TaskSchedulerProperties {
@Min(1)
private int threadPoolSize = 2;
}
} }
...@@ -9,25 +9,24 @@ ...@@ -9,25 +9,24 @@
package eu.melodic.event.control.util; package eu.melodic.event.control.util;
import eu.melodic.event.control.properties.ControlServiceProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import javax.validation.constraints.Min;
@Slf4j @Slf4j
@Configuration @Configuration
@EnableScheduling @EnableScheduling
@RequiredArgsConstructor
public class TaskSchedulerConfig { public class TaskSchedulerConfig {
@Value("${control.task-scheduler.thread-pool-size:2}") private final ControlServiceProperties properties;
@Min(1)
private int threadPoolSize;
@Bean @Bean
public ThreadPoolTaskScheduler threadPoolTaskScheduler() { public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
int threadPoolSize = properties.getTaskScheduler().getThreadPoolSize();
log.info("TaskSchedulerConfig: TaskScheduler thread pool size: {}", threadPoolSize); log.info("TaskSchedulerConfig: TaskScheduler thread pool size: {}", threadPoolSize);
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(threadPoolSize); threadPoolTaskScheduler.setPoolSize(threadPoolSize);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment