Naman Shah
Naman Shah

Reputation: 73

Setting Atmosphere settings in Vaadin SpringBootApplication

I am using JDK17 and Vaadin 22 (Flow) in a spring boot application. I wish to set the settings for atmosphere which is used by Tomcat.

I have tried the following but it does not set the values :

@SpringBootApplication
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
@Theme(value = "sample")
@PWA(name = "sample", offlineResources = {"images/logo.png"})
@Push(PushMode.AUTOMATIC)
@WebServlet(name = "springServlet", urlPatterns = "/* ", asyncSupported = true, initParams = {
        @WebInitParam(name = "org.atmosphere.cpr.broadcaster.shareableThreadPool", value = "true"),
        @WebInitParam(name = "org.atmosphere.cpr.broadcaster.maxProcessingThreads", value = "2"),
        @WebInitParam(name = "org.atmosphere.cpr.broadcaster.maxAsyncWriteThreads", value = "2"),
        @WebInitParam(name = "org.atmosphere.cpr.maxSchedulerThread", value = "2")
})
public class Application extends SpringBootServletInitializer implements AppShellConfigurator {
    public static void main(String @NotNull [] args) {
        SpringApplication.run(Application.class,
                              args);
    }
} 

Upvotes: 1

Views: 500

Answers (1)

Tatu Lund
Tatu Lund

Reputation: 10623

Try something like this

        @ManagedBean
        public class AtmosphereInitializer implements ServletContextInitializer {        
            @Override
            public void onStartup(ServletContext servletContext) {
servletContext.setInitParameter("org.atmosphere.cpr.AtmosphereConfig.getInitParameter","true"); servletContext.setInitParameter("org.atmosphere.cpr.broadcaster.maxProcessingThreads","2"); servletContext.setInitParameter("org.atmosphere.cpr.broadcaster.shareableThreadPool","true");
        ...
            }
        }

Upvotes: 1

Related Questions