如何为spring Message Broker的clientOutboundChannel配置1个线程限制?

时间:2016-09-05 13:06:22

标签: java spring-websocket

这是一个与以下问题相关的问题:

{{3}}

但我无法理解如何限制消息代理中的1个线程。

2 个答案:

答案 0 :(得分:0)

也许定义一个池大小为1的任务执行器,并将其设置为出站通道的调度程序?现在无法测试它,但它可能会有效。

在这里查看https://stackoverflow.com/a/16724743/6404321http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-configuration-performance

答案 1 :(得分:0)

您可以使用注册实例配置另一个属性。

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void configureClientOutboundChannel(ChannelRegistration registration) {
        registration.taskExecutor().maxPoolSize(1);
    }

}