Implementing a reactive web application at the server side

Spring reactive web modules support both programming models--Annotation-based or the Functional-based programming model. Let's see how these models work on the server side:

  • Annotations-based programming model: It is based on MVC annotations such as @Controller, @RestController, @RequestMapping, and many more. Annotations are supported by the Spring MVC framework for server-side programming for a web application.
  • Functional programming model: It is a new paradigm of programming supported by the Spring 5 Framework. It is based on the Java 8 Lambda style routing and handling. Scala also provides the functional programming paradigm.

The following are the Maven dependencies that we have to add for a reactive web application based on Spring Boot:

    <parent> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-starter-parent</artifactId> 
       <version>2.0.0.M3</version> 
       <relativePath/> <!-- lookup parent from repository --> 
    </parent> 
 
    <properties> 
       <project.build.sourceEncoding>UTF-
8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF
-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-test</artifactId> <scope>test</scope> </dependency> </dependencies>

As you can see in the preceding Maven configuration file for dependencies, we have added the spring-boot-starter-webflux and reactor-test dependencies to the application.

Let's create a reactive web application based on the Annotation-based programming model.

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

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