【发布时间】:2017-03-15 18:32:40
【问题描述】:
我正在使用带有 RabbitMQ 的 Spring STOMP over Websocket。一切正常,但 simpMessagingTemplate.convertAndSend 工作速度很慢,调用可能需要 2-10 秒(同步,阻塞线程)。可能是什么原因??
RabbitTemplate.convertAndSend 需要
更新
我尝试使用 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);
}
}
【问题讨论】:
-
您使用的是哪个春季版本?您能举一个转换前后的消息示例吗?
-
问的太多了,但你能试试this我的问题吗?
标签: spring spring-boot websocket rabbitmq stomp