为什么 spring-websocket 中的 STOMP 功能依赖于 Spring MVC?

Ash*_*oyi 5 stomp spring-messaging spring-websocket spring-webflux

目前,我正在尝试使用 webflux 将 STOMP 与 websockets 一起使用。为了向 STOMP 主题发送消息,我需要使用SimpMessagingTemplate,这是我添加时由 spring boot 自动配置提供的@EnableWebSocketMessageBroker

但问题是,@EnableWebSocketMessageBroker间接地希望我spring-mvc在类路径中有库

@EnableWebSocketMessageBroker @ImportsDelegatingWebSocketMessageBrokerConfiguration扩展WebSocketMessageBrokerConfigurationSupport&WebSocketMessageBrokerConfigurationSupport#stompWebSocketHandlerMapping方法期望HandlerMapping返回该类

我的问题是

  1. 如何在没有 webmvc 的情况下将 STOMP 与 webflux 集成
  2. 为什么自动配置迫使我们在类路径中有 mvc(并且可能与 webflux 冲突)

Ste*_*oll 6

如果您在 Google 上搜索“stomp webflux”,第一个命中(对我而言)是Spring Boot 问题跟踪器中的一个问题,它简要描述了为什么不支持它:

有一个总体意图是提供与 WebFlux 一致的更高级别的消息传递支持,但目前还没有特定的目标版本。请注意,我们正在研究 gRPC 和 RSocket 支持,它们属于同一一般类别。

对 RSocket 的支持已经开始,5.2所以你可能想看看。

  • 这样做会在同一应用程序中混合阻塞 I/O 和非阻塞 I/O。一种依赖于 Servlet,另一种则不依赖。这不受 Spring 团队的支持,并且可能会导致运行时问题,但它曾经有效过 (2认同)