Spring WebFlux server support

Spring Webflux supports a number of servers, as follows:

  • Netty
  • Jetty
  • Tomcat
  • Undertow
  • Servlet 3.1+ containers

Spring Boot 2+ uses Netty by default, when the web application framework selected is Spring WebFlux.

The RouterFunction created can be run on any of the servers listed previously. To do that, RouterFunction needs to be converted to HttpHandler, using the following method:

RouterFunctions.toHttpHandler(RouterFunction)

If you want to run the previously created RouterFunction in Netty, the following code snippet can be used:

HttpHandler httpHandler = RouterFunctions.toHttpHandler(movieRoutes);
ReactorHttpHandlerAdapter reactorAdapter = new ReactorHttpHandlerAdapter(httpHandler);
HttpServer server = HttpServer.create(HOST, PORT);
server.newHandler(reactorAdapter).block();

When we look at our sample application in subsequent sections of this chapter, we will look at code for other Spring WebFlux supported servers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.147.131