It is possible to enable STOMP messaging in LuciadFusion if you are extending LuciadFusion with your own code. Applications using the Spring framework usually achieve this by adding an implementation of WebSocketMessageBrokerConfigurer, which will be picked up by the Spring container. This will not work in LuciadFusion.

Due to limitations in the Spring framework, if you define your own WebSocketMessageBrokerConfigurer, part of the configuration will be overwritten by LuciadFusion. This is because LuciadFusion already defines its own WebSocketMessageBrokerConfigurer for communication with the Studio web application. To get around these limitations, create a class that extends from WebSocketMessageBrokerConfigurationSupport. This will cause the LuciadFusion configuration to be ignored.

The following code snippet shows how to enable STOMP messaging by creating a class extending from WebSocketMessageBrokerConfigurationSupport. It enables the prefixes /topic and /queue and sets the application destination prefix to /app. The /stomp path is registered as a STOMP endpoint. Since this configuration prevents the LuciadFusion configuration from being loaded, you’ll also need to enable the /studio prefix and register the /studio/service/notifications end point to ensure that notifications in the Studio web application keep working.

@Configuration
public class WebSocketConfiguration extends WebSocketMessageBrokerConfigurationSupport {

  @Override
  public void configureMessageBroker(MessageBrokerRegistry registry) {
    // The /studio prefix is used by LuciadFusion Studio for notification messages
    registry.enableSimpleBroker("/topic", "/queue", "/studio");
    registry.setApplicationDestinationPrefixes("/app");
  }

  @Override
  public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry
        .addEndpoint("/stomp")
        .setAllowedOrigins("*");

    // Endpoint used by LuciadFusion Studio for notification messages
    registry
        .addEndpoint("/studio/service/notifications")
        .setAllowedOrigins("*");
  }

  @Override
  public void configureClientOutboundChannel(ChannelRegistration registration) {
    registration.taskExecutor().corePoolSize(4).maxPoolSize(8);
  }
}