Browse Source

Update default pools size for SockJS scheduler

This change updates the XML namespace to match a change already made
to the Java config.
pull/496/head
Rossen Stoyanchev 11 years ago
parent
commit
5caf36ae91
  1. 1
      spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java
  2. 4
      spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java
  3. 10
      spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java
  4. 2
      spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java

1
spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java

@ -138,6 +138,7 @@ class WebSocketNamespaceUtils { @@ -138,6 +138,7 @@ class WebSocketNamespaceUtils {
RootBeanDefinition taskSchedulerDef = new RootBeanDefinition(ThreadPoolTaskScheduler.class);
taskSchedulerDef.setSource(source);
taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
parserContext.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
parserContext.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));

4
spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java

@ -46,6 +46,7 @@ import org.springframework.messaging.simp.user.UserSessionRegistry; @@ -46,6 +46,7 @@ import org.springframework.messaging.simp.user.UserSessionRegistry;
import org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler;
import org.springframework.messaging.support.AbstractSubscribableChannel;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.context.support.GenericWebApplicationContext;
@ -134,6 +135,9 @@ public class MessageBrokerBeanDefinitionParserTests { @@ -134,6 +135,9 @@ public class MessageBrokerBeanDefinitionParserTests {
assertNotNull(wsTransportHandler.getHandshakeHandler());
assertThat(wsTransportHandler.getHandshakeHandler(), Matchers.instanceOf(TestHandshakeHandler.class));
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) defaultSockJsService.getTaskScheduler();
assertEquals(Runtime.getRuntime().availableProcessors(), scheduler.getScheduledThreadPoolExecutor().getCorePoolSize());
UserSessionRegistry userSessionRegistry = this.appContext.getBean(UserSessionRegistry.class);
assertNotNull(userSessionRegistry);

10
spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java

@ -37,6 +37,7 @@ import org.springframework.messaging.simp.SimpMessageType; @@ -37,6 +37,7 @@ import org.springframework.messaging.simp.SimpMessageType;
import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
@ -122,6 +123,15 @@ public class WebSocketMessageBrokerConfigurationSupportTests { @@ -122,6 +123,15 @@ public class WebSocketMessageBrokerConfigurationSupportTests {
}
}
@Test
public void messageBrokerSockJsTaskScheduler() {
ThreadPoolTaskScheduler taskScheduler =
this.config.getBean("messageBrokerSockJsTaskScheduler", ThreadPoolTaskScheduler.class);
assertEquals(Runtime.getRuntime().availableProcessors(),
taskScheduler.getScheduledThreadPoolExecutor().getCorePoolSize());
}
@Controller
static class TestController {

2
spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java

@ -85,7 +85,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -85,7 +85,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
SimpleController controller = this.wac.getBean(SimpleController.class);
try {
assertTrue(controller.latch.await(2, TimeUnit.SECONDS));
assertTrue(controller.latch.await(10, TimeUnit.SECONDS));
}
finally {
session.close();

Loading…
Cancel
Save