SpringBoot WebFlux Annotation-based RestAPIs
Reactive programming is about non-blocking applications. And Spring Framework 5 includes a new spring-webflux
module, supports Reactive Streams for communicating backpressure across async components and libraries. So in the tutorial, JavaSampleApproach will guide you through the steps for creating a SpringBoot WebFlux Annotation-based restful APIs.
Related posts:
Spring WebFlux supports 2 distinct programming models:
In the tutorial, we will introduce WebFlux with Annotation-based.
For starting with WebFlux, SpringBoot supports a collection dependency: spring-boot-starter-webflux
.
Sample code:
@RestController
@RequestMapping(value="/api/customer")
public class RestControllerAPIs {
@GetMapping("/")
public Flux getAll() {
...
}
@GetMapping("/{id}")
public Mono getCustomer(@PathVariable Long id) {
...
}
}
reactor.core.publisher.Flux
: is a standard Publisher
representing a reactive sequence of 0…N items, optionally terminated by either a success signal or an error.reactor.core.publisher.Mono
: Mono
is a specialized Publisher
that emits at most single-valued-or-empty result.Step to do:
Reactive Web
dependency:
Check pom.xml
after creating:
More at:
SpringBoot WebFlux Annotation-based RestAPIs
#springboot #webflux #annotation #restapi