Search in sources :

Example 76 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-framework by spring-projects.

the class ReactorNettyTcpStompClientTests method setUp.

@Before
public void setUp() throws Exception {
    logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
    int port = SocketUtils.findAvailableTcpPort(61613);
    this.activeMQBroker = new BrokerService();
    this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port);
    this.activeMQBroker.setStartAsync(false);
    this.activeMQBroker.setPersistent(false);
    this.activeMQBroker.setUseJmx(false);
    this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
    this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
    this.activeMQBroker.start();
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.afterPropertiesSet();
    this.client = new ReactorNettyTcpStompClient("127.0.0.1", port);
    this.client.setMessageConverter(new StringMessageConverter());
    this.client.setTaskScheduler(taskScheduler);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) BrokerService(org.apache.activemq.broker.BrokerService) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Before(org.junit.Before)

Example 77 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-framework by spring-projects.

the class WebSocketConfigurationSupport method defaultSockJsTaskScheduler.

/**
	 * The default TaskScheduler to use if none is configured via
	 * {@link SockJsServiceRegistration#setTaskScheduler}, i.e.
	 * <pre class="code">
	 * &#064;Configuration
	 * &#064;EnableWebSocket
	 * public class WebSocketConfig implements WebSocketConfigurer {
	 *
	 *   public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
	 *     registry.addHandler(myWsHandler(), "/echo").withSockJS().setTaskScheduler(myScheduler());
	 *   }
	 *
	 *   // ...
	 * }
	 * </pre>
	 */
@Bean
public ThreadPoolTaskScheduler defaultSockJsTaskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setThreadNamePrefix("SockJS-");
    scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
    scheduler.setRemoveOnCancelPolicy(true);
    return scheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Bean(org.springframework.context.annotation.Bean)

Example 78 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project Protocol-Adapter-OSLP 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 79 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project Protocol-Adapter-OSLP by OSGP.

the class EveningMorningBurnersLightSwitchingOnConfig method eveningMorningBurnerslightSwitchingOnTaskScheduler.

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

Example 80 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project Protocol-Adapter-OSLP by OSGP.

the class EventNotificationTransitionConfig method eventNotificationTaskScheduler.

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

Aggregations

ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)138 Bean (org.springframework.context.annotation.Bean)43 Test (org.junit.Test)42 BeanFactory (org.springframework.beans.factory.BeanFactory)31 Test (org.junit.jupiter.api.Test)26 CountDownLatch (java.util.concurrent.CountDownLatch)19 QueueChannel (org.springframework.integration.channel.QueueChannel)19 GenericMessage (org.springframework.messaging.support.GenericMessage)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 ExecutorService (java.util.concurrent.ExecutorService)10 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)8 MqttPahoMessageDrivenChannelAdapter (org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)7 MqttPahoMessageHandler (org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler)6 JmsTemplate (org.springframework.jms.core.JmsTemplate)6 ArrayList (java.util.ArrayList)5 Log (org.apache.commons.logging.Log)5 MessageChannel (org.springframework.messaging.MessageChannel)5 File (java.io.File)4