I have synchronous code that I want to make non-blocking with reactor. I want to call in parallel different URI, the calls can return a response, an error or nothing. There are 3 cases: A request returns a response, I return it without waiting for the other requests to complete. If other requests returned errors earlier, I drop the errors
Tag: spring-webflux
How to consume infinite flux multiple times
This is what I’m trying to achieve: When somebody requests http://localhost/runIt, I would like to return data from cache that would be refreshed every 6 seconds. Below, I have a flux (always same one that is stored in map) that is first time instantiated and starts emitting numbers 0,1,2,3,4… to infinity. Is it possible to make this Spring MVC Controller
Update 1 or multiple specific field MongoDB using Spring boot WebFlux,Spring Data MongoDB Reactive and ReactiveMongoRepository
I’m newbie with java. I tried to implement update method for my API. I want to update some field of my data. Here is my data class: My service interface: And implement for services: My Controller: And Task Repository: My data in DB: My request body: I expected: But it responsed: It update my missing value in request with null
flatMap reuse response from reactive call
Currently, I have a question, something like this: User X Y The question is how do I reuse correctly the “user” and the “x” response from the previous call? Here are my solutions for marked(*) place: nested flatMap(), then can thenReturn(user) for next map(). Any issue with the scope of a variable(user) when I build a chain(nested flatMap…) like this
Flux – parallel flatMap with webclient – limit to fixed batched rate
The code I have is this: It just requests HEAD, until first 6 requests are successful. Parallelization works here, but the problem is that after 1 of the requests is complete, it immediatley triggers next request (to maintain parallelization level of 6). What I need here is to have parallelization level of 6, but in batches. So – trigger 6
How throws CustomException from reactive service to controller?
I am receiving a request in a 0.RestController and give it to the service for processing. If service doesnt throw exception, i just return HttpStatus.200, but if an exception occurs in the service, i need catch it in controller and return the status depending on the exception. Inside service, i need to use Mono.fromCallable for repo access. Well, if user
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
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():
How to limit concurrent http requests with Mono & Flux
I want to handle Flux to limit concurrent HTTP requests made by List of Mono. When some requests are done (received responses), then service requests another until the total count of waiting requests is 15. A single request returns a list and triggers another request depending on the result. At this point, I want to send requests with limited concurrency.