1
votes

Is it possible to integrate camunda-bpm-spring-boot-starter-webapp & camunda-bpm-spring-boot-starter-rest into a spring boot reactive project?

I have tried to simply integrate the packages. But when running the project, I see that only the springMVC mode is activated and eliminates all routers defined in reactive mode. The spring MVC is launched with Tomcat. However the reactive mode is configured with netty (a non-servlet server). I tried to exclude Tomcat to rely only on netty but I don't see how could I configure a servlet for it. Or is there a possibility to coexist both modes?

I expect to be able to see camunda webapp and the application routes runnning together. What I have now is only one mode can be activated : If SpringMVC : webapp OK, Routes NOK If Reactive : webapp NOK, Routes OK

2

2 Answers

2
votes

The workaround is to use tomcat as a web server instead of netty because it can handle "Spring WebFlux and Spring MVC"

Add on your gradle file

compile 'org.apache.tomcat.embed:tomcat-embed-core'

then use a ServletRegistrationBean which registers the your routing functions inside an httpServlet

@Bean
public ServletRegistrationBean routerToServlet() {
    RouterFunction<?> route = routingFunction();
    HttpHandler httpHandler = toHttpHandler(route);
    ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
    ServletRegistrationBean bean = new ServletRegistrationBean<>(servlet, "/core/*");
    bean.setLoadOnStartup(1);
    return bean;
}

Your routingFunction() is WebFlux Routes So that you have Camunda webapp OK and Routes OK

0
votes

The Spring documentation states that

Both web frameworks mirror the names of their source modules (spring-webmvc and spring-webflux) and co-exist side by side in the Spring Framework. Each module is optional. Applications can use one or the other module or, in some cases, both — for example, Spring MVC controllers with the reactive WebClient.

The project uses Webflux whereas Camunda webapps use MVC. They use MVC because the camunda-spring-boot-starter auto-configures the webapp as a Spring MVC webapp (see CamundaBpmWebappAutoConfiguration).

Maybe it would be possible to have another CamundaBpmWebappAutoConfiguration class, one which loads if in Webflux mode and implements WebFluxConfigurer ? Do you think it is worth a try ?