Version 2

    Spring Webflux

    Spring Framework 5.0 introduced a new functional web framework (based on Reactive Streams). I have read a lot of posts about Spring Webflux. Most of them show how it works under Netty.

    In this article, I would like to share my sample how it can be run on Undertow within Wildfly (I have used Wildfly 11.0).


    The Spring Web module provides the class UndertowHttpHandlerAdapter for adapting org.springframework.http.server.reactive.HttpHandler -> io.undertow.server.HttpHandler

    For more details please read this HttpHandler.

    Functional Endpoints

    Spring WebFlux provides a lightweight, functional programming model where functions are used to route and handle requests and where contracts are designed for immutability. One more interesting is a possibility for handling incoming requests via a router of functions.

    I have combined all these logic into single simple class

    Custom module

    The second step was building a custom module to be able to make a reference in the standalone.xml.

    I did it using gradle plugin and got the following module.xml:

    <?xml version='1.0' encoding='utf-8'?>
    <module xmlns='urn:jboss:module:1.6' name='com.zhurlik'>


       <resource-root path='simple-webflux-app-0.1.jar' />

       <resource-root path='spring-webflux-5.0.2.RELEASE.jar' />

       <resource-root path='spring-core-5.0.2.RELEASE.jar' />

       <resource-root path='spring-context-5.0.2.RELEASE.jar' />

       <resource-root path='spring-beans-5.0.2.RELEASE.jar' />

       <resource-root path='spring-web-5.0.2.RELEASE.jar' />

       <resource-root path='reactor-core-3.1.2.RELEASE.jar' />

       <resource-root path='reactive-streams-1.0.1.jar' />

       <resource-root path='jackson-dataformat-smile-2.9.3.jar' />

       <resource-root path='jackson-databind-2.9.3.jar' />

       <resource-root path='jackson-core-2.9.3.jar' />

       <resource-root path='jackson-annotations-2.9.0.jar' />



       <module name='io.undertow.core' />

       <module name='org.slf4j' />

       <module name='org.wildfly.extension.undertow' />

       <module name='javax.api' />

       <module name='org.apache.commons.logging' />

       <module name='org.jboss.xnio' />




    The final step is just updating the standalone.xml for enabling our custom HttpHandler:


    I hope it will be useful for somebody.