I'm using without problems spring boot 3.2.2 and if I upgrate to latest version 3.2.3 my project does not compile any more with this problem on the websocket configuration class:
StompWebSocketConfig.java:[31,8] getPhase() in org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration cannot implement getPhase() in org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
The configuration class that doesn't compile any more is this one:
@Configuration
public class StompWebSocketConfig extends WebSocketMessageBrokerConfigurationSupport implements WebSocketMessageBrokerConfigurer {
private WebSocketMessageBrokerStats webSocketMessageBrokerStats;
private final CustomOriginInterceptor customOriginInterceptor;
private final SessionCoreServices sessionCoreServices;
private final CmChannelInterceptor cmChannelInterceptor;
public StompWebSocketConfig(CustomOriginInterceptor customOriginInterceptor, SessionCoreServices ss, CmChannelInterceptor cmChannelInterceptor) {
this.customOriginInterceptor = customOriginInterceptor;
this.sessionCoreServices = ss;
this.cmChannelInterceptor = cmChannelInterceptor;
}
private TaskScheduler messageBrokerTaskScheduler;
@Autowired
public void setMessageBrokerTaskScheduler(@Lazy TaskScheduler taskScheduler) {
this.messageBrokerTaskScheduler = taskScheduler;
}
@PostConstruct
public void configureDefaults() {
if (webSocketMessageBrokerStats != null)
webSocketMessageBrokerStats.setLoggingPeriod(60 * 60 * 1000);
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/queue", "/topic")
.setHeartbeatValue(new long[]{30010, 29000})
.setTaskScheduler(this.messageBrokerTaskScheduler);
registry.setApplicationDestinationPrefixes("/app", "/topic");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/stomp").addInterceptors(customOriginInterceptor).setAllowedOrigins("*");
}
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.interceptors(cmChannelInterceptor);
}
@Bean
@Override
public WebSocketHandler subProtocolWebSocketHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) {
return new CustomSubProtocolWebSocketHandler(clientInboundChannel, clientOutboundChannel, sessionCoreServices);
}
@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registry) {
super.configureWebSocketTransport(registry);
}
@Override
public boolean configureMessageConverters(List<MessageConverter> messageConverters) {
return super.configureMessageConverters(messageConverters);
}
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
super.configureClientOutboundChannel(registration);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
}
@Override
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
super.addReturnValueHandlers(returnValueHandlers);
}
}
Comment From: scottfrederick
Thanks for getting in touch, but we'll need more information than this snippet in order to help you. If you would like us to spend some time investigating, please provide a complete minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it and attaching it to this issue.
Comment From: Polve
Putting together a full example is a bit complex for me now, but it should not be needed: the problem is just between two spring classes: I put my class just for completeness, but the only relevant line is this one:
public class StompWebSocketConfig extends WebSocketMessageBrokerConfigurationSupport implements WebSocketMessageBrokerConfigurer {
The error seems in class AbstractMessageBrokerConfiguration or WebSocketMessageBrokerConfigurer, but not really relevant to my code
getPhase() in org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration cannot implement getPhase() in org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
Comment From: wilkinsona
Neither of those classes are part of Spring Boot so I don't think there's anything that we can do here. I suspect that this is a regression due to these changes in Spring Framework. That said, implementing WebSocketMessageBrokerConfigurer while also extending AbstractMessageBrokerConfiguration is quite unusual. You'd typically do one or the other. If you want to pursue this, please open a Spring Framework issue but I would recommend restructuring your code.
Comment From: Polve
Thanks for the details, much appreciated.