Skip to content

Commit 461ba53

Browse files
CodeInDreamsrstoyanchev
authored andcommitted
Qualify channelExecutor and taskScheduler in WebSocket config
See gh-28736
1 parent d1d6eb0 commit 461ba53

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.springframework.beans.BeanUtils;
2626
import org.springframework.beans.factory.BeanInitializationException;
27+
import org.springframework.beans.factory.annotation.Qualifier;
2728
import org.springframework.context.ApplicationContext;
2829
import org.springframework.context.ApplicationContextAware;
2930
import org.springframework.context.annotation.Bean;
@@ -149,7 +150,8 @@ public ApplicationContext getApplicationContext() {
149150

150151

151152
@Bean
152-
public AbstractSubscribableChannel clientInboundChannel(TaskExecutor clientInboundChannelExecutor) {
153+
public AbstractSubscribableChannel clientInboundChannel(
154+
@Qualifier("clientInboundChannelExecutor") TaskExecutor clientInboundChannelExecutor) {
153155
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor);
154156
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
155157
ChannelRegistration reg = getClientInboundChannelRegistration();
@@ -185,7 +187,8 @@ protected void configureClientInboundChannel(ChannelRegistration registration) {
185187
}
186188

187189
@Bean
188-
public AbstractSubscribableChannel clientOutboundChannel(TaskExecutor clientOutboundChannelExecutor) {
190+
public AbstractSubscribableChannel clientOutboundChannel(
191+
@Qualifier("clientOutboundChannelExecutor") TaskExecutor clientOutboundChannelExecutor) {
189192
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor);
190193
channel.setLogger(SimpLogging.forLog(channel.getLogger()));
191194
ChannelRegistration reg = getClientOutboundChannelRegistration();
@@ -221,8 +224,9 @@ protected void configureClientOutboundChannel(ChannelRegistration registration)
221224
}
222225

223226
@Bean
224-
public AbstractSubscribableChannel brokerChannel(AbstractSubscribableChannel clientInboundChannel,
225-
AbstractSubscribableChannel clientOutboundChannel, TaskExecutor brokerChannelExecutor) {
227+
public AbstractSubscribableChannel brokerChannel(
228+
AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel,
229+
@Qualifier("brokerChannelExecutor") TaskExecutor brokerChannelExecutor) {
226230

227231
MessageBrokerRegistry registry = getBrokerRegistry(clientInboundChannel, clientOutboundChannel);
228232
ChannelRegistration registration = registry.getBrokerChannelRegistration();
@@ -411,7 +415,7 @@ public UserDestinationMessageHandler userDestinationMessageHandler(
411415
public MessageHandler userRegistryMessageHandler(
412416
AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel,
413417
SimpUserRegistry userRegistry, SimpMessagingTemplate brokerMessagingTemplate,
414-
TaskScheduler messageBrokerTaskScheduler) {
418+
@Qualifier("messageBrokerTaskScheduler") TaskScheduler messageBrokerTaskScheduler) {
415419

416420
MessageBrokerRegistry brokerRegistry = getBrokerRegistry(clientInboundChannel, clientOutboundChannel);
417421
if (brokerRegistry.getUserRegistryBroadcast() == null) {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.web.socket.config.annotation;
1818

19+
import org.springframework.beans.factory.annotation.Qualifier;
1920
import org.springframework.beans.factory.config.CustomScopeConfigurer;
2021
import org.springframework.context.ApplicationContext;
2122
import org.springframework.context.annotation.Bean;
@@ -129,8 +130,10 @@ public static CustomScopeConfigurer webSocketScopeConfigurer() {
129130
@Bean
130131
public WebSocketMessageBrokerStats webSocketMessageBrokerStats(
131132
@Nullable AbstractBrokerMessageHandler stompBrokerRelayMessageHandler,
132-
WebSocketHandler subProtocolWebSocketHandler, TaskExecutor clientInboundChannelExecutor,
133-
TaskExecutor clientOutboundChannelExecutor, TaskScheduler messageBrokerTaskScheduler) {
133+
WebSocketHandler subProtocolWebSocketHandler,
134+
@Qualifier("clientInboundChannelExecutor") TaskExecutor clientInboundChannelExecutor,
135+
@Qualifier("clientOutboundChannelExecutor") TaskExecutor clientOutboundChannelExecutor,
136+
@Qualifier("messageBrokerTaskScheduler") TaskScheduler messageBrokerTaskScheduler) {
134137

135138
WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats();
136139
stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler);

0 commit comments

Comments
 (0)