Add ability to customize message channels

@EnableWebSocketMessageBroker message channel configuration can now be
customized via WebSocketMessageBrokerConfigurer. It is necessary to
make this easy and even required as part of the basic configuration
since by default the message channels are backed by a thread pool of
size 1, not suitable for production use.

Issue: SPR-11023
This commit is contained in:
Rossen Stoyanchev
2013-11-26 16:47:48 -05:00
parent e764c8d897
commit 690051f46c
10 changed files with 431 additions and 38 deletions

View File

@@ -21,6 +21,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.util.CollectionUtils;
@@ -58,6 +59,20 @@ public class DelegatingWebSocketMessageBrokerConfiguration extends WebSocketMess
}
}
@Override
protected void configureClientInboundChannel(ChannelRegistration registration) {
for (WebSocketMessageBrokerConfigurer c : this.configurers) {
c.configureClientInboundChannel(registration);
}
}
@Override
protected void configureClientOutboundChannel(ChannelRegistration registration) {
for (WebSocketMessageBrokerConfigurer c : this.configurers) {
c.configureClientOutboundChannel(registration);
}
}
@Override
protected void configureMessageBroker(MessageBrokerRegistry registry) {
for (WebSocketMessageBrokerConfigurer c : this.configurers) {

View File

@@ -17,6 +17,7 @@
package org.springframework.web.socket.messaging.config;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
/**
@@ -35,6 +36,22 @@ public interface WebSocketMessageBrokerConfigurer {
*/
void registerStompEndpoints(StompEndpointRegistry registry);
/**
* Configure the {@link org.springframework.messaging.MessageChannel} used for
* incoming messages from WebSocket clients. By default the channel is backed
* by a thread pool of size 1. It is recommended to customize thread pool
* settings for production use.
*/
void configureClientInboundChannel(ChannelRegistration registration);
/**
* Configure the {@link org.springframework.messaging.MessageChannel} used for
* incoming messages from WebSocket clients. By default the channel is backed
* by a thread pool of size 1. It is recommended to customize thread pool
* settings for production use.
*/
void configureClientOutboundChannel(ChannelRegistration registration);
/**
* Configure message broker options.
*/