Spring bean RequestScope with Webflux

4.8k Views Asked by At

Is there a pattern to use @RequestScope with Webflux? We used the approach suggested here (https://www.baeldung.com/spring-bean-scopes) but it gives below error.

No scope registered for scope name request

1

There are 1 best solutions below

0
mslowiak On

Request scope works on ThreadLocal which is not supported by Webflux because part of work can be delegated between threads and you cannot assume that request will be handled by one thread.

In such a case, you should take a look at Reactor Context which allows you to connect data with the request scope.