spring - 使用 RabbitMQ 的 SimpMessagingTemplate.convertAndSend 工作速度很慢

标签 spring spring-boot websocket rabbitmq stomp

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

RabbitTemplate.convertAndSend 需要 < 1s,但我需要在 websocket 上踩踏..

更新

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

ActiveMQ 有默认配置。

网络套接字配置:

@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 毫秒。

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

关于spring - 使用 RabbitMQ 的 SimpMessagingTemplate.convertAndSend 工作速度很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40380069/

相关文章:

spring - 在@Component类中注册bean是否尊重@Scope?

Spring AMQP RPC 非默认交换

spring-boot - 找不到资源和ControllerLinkBuilder并已弃用

java - 后台服务占用太多内存

java - 无法解析 Spring Boot 应用程序中的符号 "security"

java - 如何在 Intellij 中使用 Tomcat 8?

spring - 使用 Java 注释使用 Spring 发送电子邮件

java - 带有目标的注释的 Spring aliasFor(参数)

ssl - 使用本地主机证书保护 websocket

go websockets with gorilla libs - 未知的 json 响应,所以无法映射它