Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During integration of Spring Boot bean of BroadcasterFactory creating without applying configuration #2520

Open
ViacheslavBondarchuk opened this issue Nov 10, 2024 Discussed in #2519 · 5 comments

Comments

@ViacheslavBondarchuk
Copy link

ViacheslavBondarchuk commented Nov 10, 2024

Discussed in #2519

Originally posted by viacheslavbondarchukk November 9, 2024
Hi, I am trying to integrate the Atmosphere Framework with Srping Boot, all work as well.
But bean of BroadcasterFactory is creating before initialization of SpirngAtmosphereServlet and AtmosphereFramework.
This leads to ignor passed configuration in SringAthomsphereContex for bean BroadcasterFactory.

Am I doing something wrong?

I followed this tutorial:
https://github.com/Atmosphere/atmosphere/wiki/Configuring-Atmosphere-as-a-Spring-Bean

Code:

@configuration
public class AtmosphereAutoConfiguration {

private static final String ATMOSPHERE_SERVLET_NAME = "AtmosphereServlet";
private static final Map<String, String> CONFIG = Map.of(// TODO: externalize it in external configuration
        ApplicationConfig.BROADCASTER_LIFECYCLE_POLICY, IDLE_EMPTY_DESTROY.name(),
        ApplicationConfig.USE_FORJOINPOOL, "false",
        ApplicationConfig.BROADCASTER_SHARABLE_THREAD_POOLS, "true",
        ApplicationConfig.BROADCASTER_ASYNC_WRITE_THREADPOOL_MAXSIZE, "200",
        ApplicationConfig.BROADCASTER_MESSAGE_PROCESSING_THREADPOOL_MAXSIZE, "100",
        ApplicationConfig.BROADCASTER_WAIT_TIME, "5",
        ApplicationConfig.BROADCASTER_FACTORY, DefaultBroadcasterFactory.class.getName(),
        ApplicationConfig.BROADCASTER_CACHE, DefaultBroadcasterCache.class.getName()
);

@Bean
public ServletRegistrationBean<AtmosphereSpringServlet> atmosphereSpringServlet() {
    ServletRegistrationBean<AtmosphereSpringServlet> servletRegistrationBean = new ServletRegistrationBean<>();
    servletRegistrationBean.setServlet(new AtmosphereSpringServlet());
    servletRegistrationBean.setAsyncSupported(true);
    servletRegistrationBean.setUrlMappings(Collections.singletonList(AtmosphereUtil.path("*")));
    servletRegistrationBean.setBeanName(ATMOSPHERE_SERVLET_NAME);
    servletRegistrationBean.setName(ATMOSPHERE_SERVLET_NAME);
    servletRegistrationBean.setLoadOnStartup(0);
    servletRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return servletRegistrationBean;
}

@Bean
public AtmosphereFramework atmosphereFramework() {
    return new AtmosphereFramework(false, false);
}

@Bean
public BroadcasterFactory broadcasterFactory(AtmosphereFramework framework) {
    return framework.getAtmosphereConfig()
            .getBroadcasterFactory();
}

@Bean
public AtmosphereSpringContext atmosphereSpringContext() {
    AtmosphereSpringContext atmosphereSpringContext = new AtmosphereSpringContext();
    atmosphereSpringContext.setConfig(CONFIG);
    return atmosphereSpringContext;
}

@Bean
public AtmosphereStreamServiceRegistrar serviceRegistrar() {
    return new AtmosphereStreamServiceRegistrar();
}

}

@ViacheslavBondarchuk ViacheslavBondarchuk changed the title During the spring boot integration bean of BroadcastFactory creates without applying configuration During integration of Spring Boot bean of BroadcastFactory creating without applying configuration Nov 10, 2024
@ViacheslavBondarchuk ViacheslavBondarchuk changed the title During integration of Spring Boot bean of BroadcastFactory creating without applying configuration During integration of Spring Boot bean of BroadcasterFactory creating without applying configuration Nov 10, 2024
@jfarcand
Copy link
Member

@ViacheslavBondarchuk Please generate a test case I can use to reproduce the issue, and I will work on it ASAP. Thanks

@viacheslavbondarchukk
Copy link

@jfarcand What me need to do exactly?
Need to create branch and add test case into tests folder?

@jfarcand
Copy link
Member

Yes that would be perfect

@viacheslavbondarchukk
Copy link

viacheslavbondarchukk commented Nov 14, 2024

OK, I will add test a little bit later

@ViacheslavBondarchuk
Copy link
Author

ViacheslavBondarchuk commented Dec 3, 2024

@jfarcand
I made the fork and pushed there my branch with tests.
https://github.com/ViacheslavBondarchuk/atmosphere-extensions/tree/spring_integration_issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants