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:
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user