Skip to content

Tag: spring-webflux

Why many people say that flatmap in reactor is one-to-many?

I’ve read that wonderful answer about the difference between map and flatMap. And there is a picture that demonstrates flatmap: And quote: The map is for synchronous, non-blocking, one-to-one transformations while the flatMap is for asynchronous (non-blocking) One-to-Many transformations. Based on that picture and quote I understand that flatMap allows the creation of more (or fewer) elements than it was

Spring boot WebFlux : How to write return value?

Exception is : Required type: Mono Provided:Mono no instance(s) of type variable(s) T exist so that Mono conforms to UserDto inference variable R has incompatible bounds: equality constraints: UserDto lower bounds: Mono How to write function getUserInfoByUserId ? Answer Assuming that you are always returning Mono from your repository methods, you can do this I would recommend you to start

Does the use of Spring Webflux’s WebClient in a blocking application design cause a larger use of resources than RestTemplate

I am working on several spring-boot applications which have the traditional pattern of thread-per-request. We are using Spring-boot-webflux to acquire WebClient to perform our RESTful integration between the applications. Hence our application design requires that we block the publisher right after receiving a response. Recently, we’ve been discussing whether we are unnecessarily spending resources using a reactive module in our

How to add @RestController to spring-webflux apps?

The annotation @RestController cannot be resolved when only adding spring-boot-starter-webflux as maven dependency: pom.xml: What is missing here? According to many resources out there (eg, the webflux dependency should be sufficient for a webflux-webservice in spring-boot. Answer RestController annotation is part of org.springframework:spring-web: dependency org.springframework:spring-web dependency is part of org.springframework.boot:spring-boot-starter-webflux jar so it should get resolved. You can check

Problem of type inference and type variance for Reactor/WebFlux

Let’s say there is an interface and its implement class as: And then, for the method Mono<InterfaceA> getMonoA(), the following implementation causes a compile error: It makes sense that the invariance type Mono<InterfaceA> is not the super class of Mono<ClassA> even if InterfaceA is the super class of ClassA and therefore the return type of ClassA.getMonoA() which is Mono<ClassA> does

How to chain reactive calls correctly and sequentially

I am trying to make calls with the following order: save an object publish an object creation event, only if the first step is done Return a Flux list What I have currently is following: Would this work and publish event as requested, or should I use zipWhen() instead of doOnSuccess()? Answer doOn… are so-called side-effect operators and should not