使用 RabbitMQ 的 SimpMessagingTemplate.convertAndSend 工作速度很慢 [英] SimpMessagingTemplate.convertAndSend with RabbitMQ works very slow

查看:33
本文介绍了使用 RabbitMQ 的 SimpMessagingTemplate.convertAndSend 工作速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using spring STOMP over Websocket with RabbitMQ. All works fine but simpMessagingTemplate.convertAndSend works very slow, call can take 2-10 seconds (synchronously, block thread). What can be a reason??

RabbitTemplate.convertAndSend 取

1s,但我需要踩过 websocket..

RabbitTemplate.convertAndSend take < 1s, but I need stomp over websocket..

更新

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

I try to use ActiveMQ and gets the same result. convertAndSend take 2-10 seconds

ActiveMQ 有默认配置.

ActiveMQ have default configuration.

网络套接字配置:

@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);
    }
}

推荐答案

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

Problem resolved. Its bug in io.projectreactor library version 2.0.4.RELEASE. I change to 2.0.8.RELEASE and its fixed problem. Sending message now take ~50ms.

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-net</artifactId>
        <version>2.0.8.RELEASE</version>
    </dependency>

这篇关于使用 RabbitMQ 的 SimpMessagingTemplate.convertAndSend 工作速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆