问题描述
我正在使用RabbitMQ在Websocket上使用spring STOMP.一切正常,但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.
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);
}
}
推荐答案
问题已解决.它在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运行非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!