The annotation @RestController cannot be resolved when only adding spring-boot-starter-webflux as maven dependency: pom.xml: What is missing here? According to many resources out there (eg https://medium.com/javarevisited/basic-introduction-to-spring-webflux-eb155f501b17), the webflux dependency should be sufficient for a webflux-webservice in spring-boot. Answer RestController annotation is part of org.springframework:spring-web: dependency org.springframework:spring-web dependency is part of org.springframework.boot:spring-boot-starter-webflux jar so it should get resolved. You can check
Tag: spring-webflux
How to deploy a Spring-Boot-Webflux application to Tomcat standalone server?
A normal spring-web application can be deployed to tomcat standalone as war file as follows: Question: how can I deploy such an application after migrating to spring-webflux to tomcat? Docs say: https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#webflux-httphandler To deploy as a WAR to any Servlet 3.1+ container, you can extend and include AbstractReactiveWebInitializer in the WAR. That class wraps an HttpHandler with ServletHttpHandlerAdapter and registers
How do I increase the default timeout in the Cassandra Java driver using the DriverConfigLoader?
Small question regarding a Spring Webflux Reactive Cassandra application please. On a setup Spring Boot 2.6.4 with Webflux and reactive Cassandra, I am using the app to insert some data in Cassandra tables. Things works fine, until when there is a higher load, I am seeing an issue (stack trace attached) The thing is, reading some documentation, I thought this
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
How to setServletPath() in Spring Junit WebTestClient?
This creates a MockHttpServletRequest that is send to the @RestContoller servlets. Problem: my servlets make use of HttpServletRequest.getServletPath(), but which is always empty using the WebTestClient approach above. Question: how can I explicit set the servletPath in my junit tests? Answer I could solve it as follows, but as this is really hacky, I’d still appreciate a proper solution.
Spring: re-initialized a bean
This is my Spring bean in the configuration class that creates a gRPC ManagedChannel: The controller method is provided below: The service class is: For each request, I create a new ManagedChannel in the service method processRequest and shut it down using the method called shutdownManagedChannel. Earlier, I try to use the @Autowired for the managed channel as below: This
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
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
Spring WebClient Retry Logic with new Headers
I am trying to build a retry logic using Spring WebClient. The problem that I am trying to solve is very simple. I am calling an API endpoint to get some values. If the API returns an error with say 401 response, then I will have to make call to Token service and renew my token and use the new