Questions tagged [webflux]
101 questions
13
votes
1 answer
How to use "cache" method of Mono
I'm a beginner of spring webflux. While researching I found some code like:
Mono result = someMethodThatReturnMono().cache();
The name "cache" tell me about caching something, but where is the cache and how to retrieve cached things? Is it…

SoT
- 898
- 1
- 15
- 36
7
votes
1 answer
I can't understand how event loop works in spring webflux
I'm trying to understand reactive programming and how the event loop works. As long as I can understand when a new HTTP request is sent to the app, this request splits into events. And every event is handled by this event loop and for every event a…

Peter
- 141
- 1
- 9
6
votes
2 answers
Netty Decoding failed DefaultFullHttpRequest
I am currently developing using spring boot webflux. I am using websocket clients and APIs clients, but this error occurs a few hours after deployment. I couldn't figure out where this error was coming from. Where does this problem come from?
The…

chb
- 107
- 2
- 8
5
votes
1 answer
Unit testing retry in Spring Webflux with mocked response
During unit testing retry the response of the mock seems cached, or most probably I am doing something wrong.
I am trying to request something, if error happened then retry twice with delay of 1 second.
public Mono

Hatik
- 1,139
- 1
- 15
- 33
5
votes
0 answers
Spring Webflux cpu in a container environment
In our environment with kubernetes, our pods usually have less than 1 cpu core reserved.
Knowing that spring webflux works with the concept of eventloop + workers,
how would that work? is it recommended that we reserve at least 1 cpu core for this…

Jean Robert
- 749
- 1
- 7
- 20
3
votes
0 answers
How to reduce cyclomatic complexity on a reactive code?
I have a microservice using Spring Webflux that makes some requests to another services. The code looks like this:
public class ExampleService {
@Autowired
private WebClient webClient;
…

David Carracedo
- 31
- 1
3
votes
0 answers
Spring Boot webflux - offload requests to a different threadpool
I'm using webflux with netty reactor.
The framework allows registering a regular blocking method (e.g that returns a string or some POJO) in a @RestController class.
The issue with that is the requests are running on netty's event loop, which you…

O. Gur
- 31
- 1
3
votes
3 answers
Why can't a Mono hold a NULL
Mono.just(null) will not compile. Why is that?
On a procedural level I get it. It does not make sense to have a processing queue without something to process. Can someone phrase this for me with some more technical depth?

nykon
- 504
- 4
- 18
3
votes
1 answer
Spring Webflux / Reactor: reactor-http-nio vs boundedElastic
I'm a bit confused on some reactor concepts on what thread model each request falls on. I read https://projectreactor.io/docs/core/release/reference but it's still not clear. Let's see an example:
@Autowired
UserRepository…

Rafael Fogel
- 33
- 3
3
votes
1 answer
how to use Reactor3's Context in SpringCloud Gateway
I tried to use the context to set some value of Reactor3 in the filter of SpringCloud Gateway but in the controller,I can't get the value in the Context.
Actually, I am new to Reactor3. So please give me some tips or help, thank you very much!
//my…

LI_guoyu
- 31
- 1
3
votes
2 answers
SpringBoot - Generic function for WebFlux getting ClassCastException
I'm trying to write a generic function to do some Webflux operations and I'm getting a class cast exception that I can't figure out
* @param Type of the contract
* @param Return type of this method
* @param Return type…

Peter Kronenberg
- 878
- 10
- 32
2
votes
1 answer
How to use Spring WebClient to make multiple calls simultaneously and get response separately?
I have to execute multiple API calls simultaneously which are independent of each other:
Mono response1= this.webClient
.post()
.uri(requestURI1)
.body(Flux.just(request.getRequestBody()),…

Abhishek Wadhwa
- 53
- 1
- 5
2
votes
0 answers
Reactor log with MDC context within map
In my Spring Webflux application to have tracing headers in the logs (MDC) I have followed the FAQ from Reactor (https://projectreactor.io/docs/core/release/reference/#faq.mdc). It works nice. However, it is not suitable when I need to add logs with…

Adam
- 884
- 7
- 29
2
votes
1 answer
How to get current authenticated user in Spring WebFlux
I'm trying to retrieve authentication object, which creates user name and permissions.
I know that in WebFlux I cannot use SecurityContextHolder.getContext(), but rather must use ReactiveSecurityContextHolder.getContext()
But in both cases, result…

Victor Mikhailov
- 113
- 12
2
votes
0 answers
Deserialize header to Pojo in Webflux?
I have a header that's some encoded Json, so I have a POJO to deserialize it to.
How do I make Spring Boot auto deserialize it?
I've tried creating a @Component Test implements Converter but it never gets called. The one example I…

SledgeHammer
- 7,338
- 6
- 41
- 86