Skip to content
Advertisement

Tag: project-reactor

Time Elapsed for Mono Webflux

I am calling a post endpoint that returns a Void. I am trying to get the time elapsed. It seems it is not calling an endpoint. doOnSuccess is also not getting called. Answer elapsed() measures the time between when the Mono is subscribed to and the moment the Mono emits an item. But, Mono<Void> response doesn’t emit any value. You

Process List with synchronous delay after flatMap?

Hey I just started to dive into reactive programming and I can’t figure out how to process a List<String> in a synchronous way after flatMap. What I am trying to achieve: Get domain list from external service Filter out existing domains in database Make another http request to external service to get domain info. These calls should be executed in

Building a Recursive Data Structure with Spring WebFlux

I have a REST API that is built with the Spring WebFlux framework, and I have an endpoint which returns a Flux<ChannelResponse>, where ChannelResponse is a tree-structured object, as shown below: Now, I don’t have much experience with the reactive programming paradigm, but this is how I would implement such an endpoint with synchronous logic, such that each top-level channel

Convert Flux into Flux

I am working on spring webflux file upload. From the controller I want to upload the file on amazon S3 bucket. So in the controller I received following object And from the FilePart.content() I can get My question is how can I convert this Flux<DataBuffer> into Flux<ByteBuffer>. I mean into the following object Answer You can simply use the org.springframework.core.io.buffer.DataBuffer#asByteBuffer():

Reactive – Improve Mono syntax

I have this block of code that works fine: To summarize it: calls the isBlacklistedToken function (returns a Mono<Boolean> with the result of the refresh token) If the refresh token is blacklisted, throws an UnauthorizedException If the refresh token is not blacklisted, does the same process for the access token If both tokens are not blacklisted, finally blacklists them. This

ReactiveCrudRepository vs. R2dbcRepository

I am learning the reactive stack starting with R2DBC and this is what I don’t understand: What are the differences between these, when to use them, and how relevant the @Repository stereotype annotation is to them? org.springframework.data.r2dbc.repository.R2dbcRepository org.springframework.data.repository.reactive.ReactiveCrudRepository; As far as I understand, both of them are @NoRepositoryBean and both are shipped together through the org.springframework.boot:spring-boot-starter-data-r2dbc dependency. Answer There is

Update objects’s state in Reactor

Given the following method: switchIfEmpty and map operators mutate the profileUpdate object. Is it safe to mutate in switchIfEmpty operator? Regarding map, if I have understood correctly, this is not safe and object profileUpdate must be immutable, right? eg: Later in the chain, another method mutates the object: The above methods are called as follows: Answer Nebulous answer, but… it

How to convert Flux<List> into Mono<List>

I have a service which returns Flux<List<Integer>> and I would like to convert it into Mono<List<Integer>> to be used inside transform() Here is what I did by using flatMap and Mono.just(): But what I would like is to use transform instead: Is there any operator or technique to make method2 to work? As a result I expect onNext() be called

Advertisement