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

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

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

Loading…
Cancel
Save