使用RabbitMQ的SimpMessagingTemplate.convertAndSend工作非常慢

Nic*_*nko 12 spring stomp rabbitmq websocket spring-boot

我正在使用带有RabbitMQ的Spring STOMP over Websocket.一切正常,但simpMessagingTemplate.convertAndSend工作很慢,调用可能需要2-10秒(同步,阻塞线程).可能是什么原因?

RabbitTemplate.convertAndSend取<1s,但我需要踩过websocket ..

UPDATE

我尝试使用ActiveMQ并获得相同的结果.convertAndSend需要2-10秒

ActiveMQ具有默认配置.

Web套接字配置:

@Configuration
@EnableWebSocket
@EnableWebSocketMessageBroker
class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableStompBrokerRelay("/topic", "/queue", "/exchange");
        config.setApplicationDestinationPrefixes("/topic", "/queue"); // prefix in client queries
        config.setUserDestinationPrefix("/user");
    }

    @Override
    void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/board").withSockJS()
    }

    @Override
    void configureWebSocketTransport(WebSocketTransportRegistration registration) {
        registration.setMessageSizeLimit(8 * 1024);
    }
}
Run Code Online (Sandbox Code Playgroud)

Nic*_*nko 8

问题解决了.它在io.projectreactor库版本2.0.4.RELEASE中的错误.我改为2.0.8.RELEASE及其固定的问题.现在发送消息大约需要50ms.

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-net</artifactId>
        <version>2.0.8.RELEASE</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)