6

Currently, I am trying to use STOMP with websockets using webflux. In order to send a message to a STOMP topic, I need to use SimpMessagingTemplate, which is contributed by spring boot auto configuration when I add @EnableWebSocketMessageBroker

But the problem with this is, @EnableWebSocketMessageBroker indirectly expects me to have spring-mvc library in classpath

@EnableWebSocketMessageBroker @Imports DelegatingWebSocketMessageBrokerConfiguration which extends WebSocketMessageBrokerConfigurationSupport & WebSocketMessageBrokerConfigurationSupport#stompWebSocketHandlerMapping method expects the class HandlerMapping to be returned

My question is

  1. How to integrate STOMP with webflux without webmvc
  2. Why is the autoconfiguration forcing us to have mvc in classpath (and potentially conflict with webflux)
Ashok Koyi
  • 5,327
  • 8
  • 41
  • 50

1 Answers1

6

If you search for "stomp webflux" on Google, the very first hit (for me) is an issue in the Spring Boot issue tracker that shortly describes why it isn't supported:

There is a general intent to provide higher-level, messaging support aligned with WebFlux, but there is no specific target release yet. Note that we are researching gRPC and RSocket support, which are in the same general category.

Support for RSocket has been started in the 5.2 line so you may want to have a look to that.

Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89
  • Thanks for the answer. I already went over the links you shared. Since the issue is more than an year old, I wanted to cross check. Also, since choosing RSocket is not a minor decision, I wanted to see if there is a reason why we have just webmvc support for STOMP despite `WebSocketHandler` returning `Mono`. Also, since `HandlerMapping` from webmvc is only present in a single place in the whole of `@EnableWebSocketMessageBroker`, is it possible for me to replace the servlet `HandlerMapping` with webflux `HandlerMapping` & still work with STOMP? – Ashok Koyi Apr 08 '19 at 08:14
  • STOMP is currently not supported with WebFlux. – Stephane Nicoll Apr 08 '19 at 08:20
  • Thanks for the clarification. I'll try and see if replacing the servlet `HandlerMapping` with webflux `HandlerMapping` works – Ashok Koyi Apr 08 '19 at 08:29
  • 2
    Doing so will mix blocking I/O and non-blocking I/O in the same application. One relies on Servlet the other doesn’t. This is not supported by the Spring team and is likely to cause runtime issue, it it ever works at all – Brian Clozel Apr 08 '19 at 09:42
  • Hi, I am saying exactly the same. My question was, since current version has hard dependency on HandlerMapping from webmvc, instead of having both blocking & non blocking variants, can I just replace HandlerMapping from webmvc with `org.springframework.web.reactive.HandlerMapping` from webflux so that I have just a single version (just webflux variant) that knows how to deal with the URL – Ashok Koyi Apr 11 '19 at 13:44