This is specific to rSocket.
Add support for global @MessageExceptionHandler using @ControllerAdvice. Currently @MessageExceptionHandler needs to be part of same controller to handle issues.
Comment From: rstoyanchev
@ControllerAdvice
and ControllerAdviceBean
are in spring-web unfortunately and spring-messaging cannot depend on that.
What we could do however is expose a method in RSocketMessageHandler
to accept MessagingAdviceBean
registrations, which is an interface that can be implemented as a simple wrapper/delegate around a ControllerAdviceBean
. That leaves only a small amount of glue code to be done by the application:
ControllerAdviceBean.findAnnotatedBeans(context).forEach(controllerAdviceBean ->
rsocketMessageHandler.registerAdviceBean(new MessagingAdviceBeanWrapper(controllerAdviceBean));
Spring Boot can probably do that automatically in its RSocketMessagingAutoConfiguration
.