Browse Source

Qualify channelExecutor and taskScheduler in WebSocket config

See gh-28736
pull/28780/head
CodeInDreams 4 years ago committed by rstoyanchev
parent
commit
461ba53b39
  1. 14
      spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java
  2. 7
      spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java

14
spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java

@ -24,6 +24,7 @@ import java.util.Map;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -149,7 +150,8 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
@Bean @Bean
public AbstractSubscribableChannel clientInboundChannel(TaskExecutor clientInboundChannelExecutor) { public AbstractSubscribableChannel clientInboundChannel(
@Qualifier("clientInboundChannelExecutor") TaskExecutor clientInboundChannelExecutor) {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor); ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor);
channel.setLogger(SimpLogging.forLog(channel.getLogger())); channel.setLogger(SimpLogging.forLog(channel.getLogger()));
ChannelRegistration reg = getClientInboundChannelRegistration(); ChannelRegistration reg = getClientInboundChannelRegistration();
@ -185,7 +187,8 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
} }
@Bean @Bean
public AbstractSubscribableChannel clientOutboundChannel(TaskExecutor clientOutboundChannelExecutor) { public AbstractSubscribableChannel clientOutboundChannel(
@Qualifier("clientOutboundChannelExecutor") TaskExecutor clientOutboundChannelExecutor) {
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor); ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor);
channel.setLogger(SimpLogging.forLog(channel.getLogger())); channel.setLogger(SimpLogging.forLog(channel.getLogger()));
ChannelRegistration reg = getClientOutboundChannelRegistration(); ChannelRegistration reg = getClientOutboundChannelRegistration();
@ -221,8 +224,9 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
} }
@Bean @Bean
public AbstractSubscribableChannel brokerChannel(AbstractSubscribableChannel clientInboundChannel, public AbstractSubscribableChannel brokerChannel(
AbstractSubscribableChannel clientOutboundChannel, TaskExecutor brokerChannelExecutor) { AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel,
@Qualifier("brokerChannelExecutor") TaskExecutor brokerChannelExecutor) {
MessageBrokerRegistry registry = getBrokerRegistry(clientInboundChannel, clientOutboundChannel); MessageBrokerRegistry registry = getBrokerRegistry(clientInboundChannel, clientOutboundChannel);
ChannelRegistration registration = registry.getBrokerChannelRegistration(); ChannelRegistration registration = registry.getBrokerChannelRegistration();
@ -411,7 +415,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
public MessageHandler userRegistryMessageHandler( public MessageHandler userRegistryMessageHandler(
AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel,
SimpUserRegistry userRegistry, SimpMessagingTemplate brokerMessagingTemplate, SimpUserRegistry userRegistry, SimpMessagingTemplate brokerMessagingTemplate,
TaskScheduler messageBrokerTaskScheduler) { @Qualifier("messageBrokerTaskScheduler") TaskScheduler messageBrokerTaskScheduler) {
MessageBrokerRegistry brokerRegistry = getBrokerRegistry(clientInboundChannel, clientOutboundChannel); MessageBrokerRegistry brokerRegistry = getBrokerRegistry(clientInboundChannel, clientOutboundChannel);
if (brokerRegistry.getUserRegistryBroadcast() == null) { if (brokerRegistry.getUserRegistryBroadcast() == null) {

7
spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java

@ -16,6 +16,7 @@
package org.springframework.web.socket.config.annotation; package org.springframework.web.socket.config.annotation;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.CustomScopeConfigurer; import org.springframework.beans.factory.config.CustomScopeConfigurer;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -129,8 +130,10 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac
@Bean @Bean
public WebSocketMessageBrokerStats webSocketMessageBrokerStats( public WebSocketMessageBrokerStats webSocketMessageBrokerStats(
@Nullable AbstractBrokerMessageHandler stompBrokerRelayMessageHandler, @Nullable AbstractBrokerMessageHandler stompBrokerRelayMessageHandler,
WebSocketHandler subProtocolWebSocketHandler, TaskExecutor clientInboundChannelExecutor, WebSocketHandler subProtocolWebSocketHandler,
TaskExecutor clientOutboundChannelExecutor, TaskScheduler messageBrokerTaskScheduler) { @Qualifier("clientInboundChannelExecutor") TaskExecutor clientInboundChannelExecutor,
@Qualifier("clientOutboundChannelExecutor") TaskExecutor clientOutboundChannelExecutor,
@Qualifier("messageBrokerTaskScheduler") TaskScheduler messageBrokerTaskScheduler) {
WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats(); WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats();
stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler); stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler);

Loading…
Cancel
Save