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
Tag: project-reactor
How make sequential API calls and merge the result in a mono
I try to make sequential API calls and merge the result in a mono . The first API contains a List of Id for the second API. My functional WebClient The ouvrageClient was invoked but I don’t see log Log The ouvrageClient was invoked but I don’t see log for the ouvrageClient …. and the global result of my AggregateService
How to buffer and group elements in Reactor Flux in Java
Given an infinite flux of objects, where each object has an ID, how can I use flux to create a buffered list of updates grouped by ID property (keeping the last emitted value)? Thanks Example Something like the following would be perfect but it seems to wait the end of the flux in my tests instead of buffering. It works
Webflux collectMap resulting Mono<Map<String, Mono>>
I’m quite new in the reactive world My code looks like this: The result is of type Map<String, Mono<String>> . I would like it to be of type Map<String, String>. Any ideas? Answer I suggest to use flatMap operator before collecting the elements into a Map
Calling blocking endpoint on non-blocking asynchronous service
If my reactive endpoint needs to call an external, non-reactive endpoint which does blocking stuff, is my reactive endpoint still reactive? I have 2 services running that levergaes Spring Boot MVC and Spring Webflux. Service A Spring Webflux Service B Spring MVC Now my Service A which is reactive calling the Service B endpoint which is blocking. Will my service
Spring WebClient corrupts binary data
I’m sending files containing binary data from service A to service B. When the number of files is relatively small (let’s say 5) everything works well. However, when I try to send more files (let’s say several hundred) it sometimes fails. I tried to check what is happening with this binary data, and it looks like WebClient corrupts it in
How to emit filtered out error if flux is empty
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
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
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