我正在使用 spring STOMP over Websocket 和 RabbitMQ。一切正常,但 simpMessagingTemplate.convertAndSend 工作速度非常慢,调用可能需要 2-10 秒(同步,阻塞线程)。能有什么理由吗??
RabbitTemplate.convertAndSend 需要
UPDATE
我尝试使用 ActiveMQ 并得到相同的结果。转换并发送需要 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)